private tools()
	{
		ilTool tool;
		string installRoot = null;
		//find locations of ildasm and ilasm
		RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\.NETFramework");
		if (reg != null)
		{
			if (reg.GetValue("sdkInstallRootv1.1") != null)
			{
				tool = new ilTool();
				tool.Path = (string)reg.GetValue("sdkInstallRootv1.1") + "bin\\ildasm.exe";
				tool.Version = "v1.1";
				IlDasm.Add(tool);
			}
			if (reg.GetValue("sdkInstallRootv2.0") != null)
			{
				tool = new ilTool();
				tool.Path = (string)reg.GetValue("sdkInstallRootv2.0") + "bin\\ildasm.exe";
				System.Windows.Forms.MessageBox.Show(tool.Path);
				tool.Version = "v2.0";
				IlDasm.Add(tool);
			}
			installRoot = (string)reg.GetValue("InstallRoot");
			reg.Close();
			//add custom
			tool = new ilTool();
			tool.Path = null;
			tool.Version = "Custom";
			IlDasm.Add(tool);
		}
		//find ilasm
		if (installRoot != null)
		{
			string[] dirs = Directory.GetDirectories(installRoot);
			//search install root for directories than contain ilasm.exe
			foreach (string str in dirs)
			{
				if (File.Exists(str + Path.DirectorySeparatorChar + "ilasm.exe"))
				{
					tool = new ilTool();
					//use directory as version string
					int last = str.LastIndexOf(Path.DirectorySeparatorChar);
					if (last != -1)
					{
						tool.Version = str.Substring(last + 1, str.Length - last - 1);
					}
					else
						tool.Version = str;
					tool.Path = str + Path.DirectorySeparatorChar + "ilasm.exe";
					IlAsm.Add(tool);
				}
			}
		}
		//custom
		tool = new ilTool();
		tool.Path = null;
		tool.Version = "Custom";
		IlAsm.Add(tool);
	}
	public dll(string DllFilename)
	{
		dllFile = DllFilename;
		//do this properly
		tempDir = Path.GetTempFileName();
		ilFile = tempDir + Path.DirectorySeparatorChar + ilFileName;
		resFile = Path.GetDirectoryName(ilFile) + Path.DirectorySeparatorChar
			+ Path.GetFileNameWithoutExtension(ilFile) + ".res";
		File.Delete(tempDir);
		Directory.CreateDirectory(tempDir);

		//just use the first ilAsm and ilDasm for now
		ilAsm = (ilTool)Tools.IlAsm[0];
		ilDasm = (ilTool)Tools.IlDasm[0];
	}
	private void ilAsmVersion_SelectedIndexChanged(object sender, EventArgs e)
	{
		//ilAsm version changed
		ilAsm = (ilTool) Tools.IlAsm[ilAsmVersion.SelectedIndex];
	}
	public main(string[] arg)
	{
		args = arg;

		Text = "dll_tool";
		Size = new Size(600,580);
		this.Load += new EventHandler(main_Load);
		this.Disposed += new EventHandler(main_Disposed);

		//ilasm
		Tools = tools.GetInstance();
		//make sure ilasm and ildasm are installed.
		if (Tools.IlAsm.Count == 0)
		{
			MessageBox.Show("ilasm.exe not found.\nInstall .Net SDK.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
		if (Tools.IlDasm.Count == 0)
		{
			MessageBox.Show("ildasm.exe not found.\nInstall .Net SDK.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
		if (Tools.IlAsm.Count > 0)
            ilAsm = (ilTool) Tools.IlAsm[Tools.IlAsm.Count - 1];
		if (Tools.IlDasm.Count > 0)
			ilDasm = (ilTool) Tools.IlDasm[Tools.IlDasm.Count - 1];

		//don't select "Custom" version if other versions exist
		if (Tools.IlAsm.Count > 1)
			ilAsm = (ilTool) Tools.IlAsm[Tools.IlAsm.Count - 2];
		if (Tools.IlDasm.Count > 1)
			ilDasm = (ilTool) Tools.IlDasm[Tools.IlDasm.Count - 2];

		//load button
		Button load = new Button();
		load.Parent = this;
		load.Text = "&Load";
		load.Width -= 10;
		load.Location = new Point(10,10);
		load.Click += new EventHandler(load_Click);

		//build button
		build = new Button();
		build.Parent = this;
		build.Text = "&Build";
		build.Location = new Point(85,10);
		build.Width -= 10;
		build.Enabled = false;
		build.Click += new EventHandler(build_Click);

		//load settings button
		Button loadDsf = new Button();
		loadDsf.Parent = this;
		loadDsf.Text = "Load .dsf";
		loadDsf.Width -= 10;
		loadDsf.Location = new Point(160, 10);
		loadDsf.Click += new EventHandler(loadDsf_Click);

		//save settings button
		Button saveDsf = new Button();
		saveDsf.Parent = this;
		saveDsf.Text = "Save .dsf";
		saveDsf.Width -= 10;
		saveDsf.Location = new Point(235, 10);
		saveDsf.Click += new EventHandler(saveDsf_Click);

		//about button
		Button about = new Button();
		about.Parent = this;
		about.Text = "About";
		about.Width -= 10;
		about.Location = new Point(310, 10);
		about.Click += new EventHandler(about_Click);

		//exit button
		Button exit = new Button();
		exit.Parent = this;
		exit.Text = "E&xit";
		exit.Width -= 10;
		exit.Location = new Point(385, 10);
		exit.Click += new EventHandler(exit_Click);

		//edit il before build checkbox
		editIl = new CheckBox();
		editIl.Parent = this;
		editIl.Text = "&Edit il before build";
		editIl.Width = 122;
		editIl.Location = new Point(this.Width - editIl.Width - 10, 5);
		editIl.Anchor = AnchorStyles.Top | AnchorStyles.Right;

		//ilasm label
		Label lab = new Label();
		lab.Parent = this;
		lab.AutoSize = true;
		lab.Location = new Point(5, 45);
		lab.Text = "ilAsm";

		//ilasm combobox
		ilAsmVersion = new ComboBox();
		ilAsmVersion.Parent = this;
		ilAsmVersion.DropDownStyle = ComboBoxStyle.DropDownList;
		ilAsmVersion.Width = 80;
		ilAsmVersion.Location = new Point(lab.Width + lab.Left, 40);
		foreach(ilTool iltool in Tools.IlAsm)
			ilAsmVersion.Items.Add(iltool.Version);
		ilAsmVersion.SelectedIndex = ilAsmVersion.Items.Count - 1;
		//don't select custom
		if (ilAsmVersion.Items.Count > 1)
			ilAsmVersion.SelectedIndex = ilAsmVersion.Items.Count - 2;
		ilAsmVersion.SelectedIndexChanged += new EventHandler(ilAsmVersion_SelectedIndexChanged);

		//ildasm label
		lab = new Label();
		lab.Parent = this;
		lab.AutoSize = true;
		lab.Location = new Point(ilAsmVersion.Left + ilAsmVersion.Width + 5, 45);
		lab.Text = "ilDasm";

		//ildasm combobox
		ilDasmVersion = new ComboBox();
		ilDasmVersion.Parent = this;
		ilDasmVersion.DropDownStyle = ComboBoxStyle.DropDownList;
		ilDasmVersion.Width = 80;
		ilDasmVersion.Location = new Point(lab.Left + lab.Width, 40);
		foreach(ilTool iltool in Tools.IlDasm)
			ilDasmVersion.Items.Add(iltool.Version);
		ilDasmVersion.SelectedIndex = ilDasmVersion.Items.Count - 1;
		//don't select "custom";
		if (ilDasmVersion.Items.Count > 1)
			ilDasmVersion.SelectedIndex = ilDasmVersion.Items.Count - 2;
		ilDasmVersion.SelectedIndexChanged += new EventHandler(ilDasmVersion_SelectedIndexChanged);

		//exports type combobox
		exportsType = new ComboBox();
		exportsType.Parent = this;
		exportsType.DropDownStyle = ComboBoxStyle.DropDownList;
		exportsType.Width = 80;
		exportsType.Location = new Point(this.Width - exportsType.Width - 20, 40);
		exportsType.Items.Add("Cdecl");
		exportsType.Items.Add("StdCall");
		exportsType.SelectedIndex = 0;
		exportsType.Anchor = AnchorStyles.Top | AnchorStyles.Right;

		//exports type label
		lab = new Label();
		lab.Parent = this;
		lab.AutoSize = true;
		lab.Location = new Point(exportsType.Left - lab.Width - 120, 45);
		lab.Text = "Moved methods will be";
		lab.Anchor = AnchorStyles.Top | AnchorStyles.Right;

		//methods groupbox
		GroupBox gb = new GroupBox();
		gb.Parent = this;
		gb.Text = "Methods";
		gb.Location = new Point(10, 70);
		gb.Size = new Size(230, 150);

		//method listview
		methodBox = new ListView();
		methodBox.Parent = gb;
		methodBox.Location = new Point(10, 15);
		methodBox.Size = new Size(210,130);
		methodBox.Columns.Add("method",200,HorizontalAlignment.Left);
		methodBox.Columns.Add("full",5,HorizontalAlignment.Left);
		methodBox.View = View.Details;

		//exports groupbox
		gb = new GroupBox();
		gb.Parent = this;
		gb.Text = "Exports";
		gb.Location = new Point(290, 70);
		gb.Size = new Size(290, 150);
		gb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

		//exports listview
		exportBox = new ListView();
		exportBox.Parent = gb;
		exportBox.Location = new Point(10, 15);
		exportBox.Size = new Size(270, 130);
		exportBox.Columns.Add("method", 95, HorizontalAlignment.Left);
		exportBox.Columns.Add("calling conv", 70, HorizontalAlignment.Left);
		exportBox.Columns.Add("export", 95, HorizontalAlignment.Left);
		exportBox.Columns.Add("full", 5, HorizontalAlignment.Left);
		exportBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
		exportBox.View = View.Details;
		exportBox.ItemActivate += new EventHandler(exportBox_ItemActivate);

		//move left button
		Button leftBtn = new Button();
		leftBtn.Parent = this;
		leftBtn.Text = "&<";
		leftBtn.Location = new Point(250, 150);
		leftBtn.Size = new Size(30,70);
		leftBtn.Click += new EventHandler(leftBtn_Click);

		//move right button
		Button rightBtn = new Button();
		rightBtn.Parent = this;
		rightBtn.Text = "&>";
		rightBtn.Location = new Point(250, 75);
		rightBtn.Size = new Size(30, 70);
		rightBtn.Click += new EventHandler(rightBtn_Click);

		//string table groupbox
		gb = new GroupBox();
		gb.Parent = this;
		gb.Text = "String Table";
		gb.Location = new Point(10,230);
		gb.Size = new Size(570,145);
		gb.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

		//string table listbox
		stringBox = new ListBox();
		stringBox.Parent = gb;
		stringBox.Location = new Point(10,15);
		stringBox.Size = new Size(450, 125);
		stringBox.DoubleClick += new EventHandler(stringBox_DoubleClick);
		stringBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

		//add string table checkbox
		stringCheck = new CheckBox();
		stringCheck.Parent = gb;
		stringCheck.Text = "Add string table";
		stringCheck.Location = new Point(465, 15);
		stringCheck.Size = new Size(102, 20);
		stringCheck.Anchor = AnchorStyles.Top | AnchorStyles.Right;

		// generate string table button
		Button strBtn = new Button();
		strBtn.Parent = gb;
		strBtn.Text = "&Generate";
		strBtn.Width += 20;
		strBtn.Height -= 5;
		strBtn.Location = new Point(465, 40);
		strBtn.Anchor = AnchorStyles.Top | AnchorStyles.Right;
		strBtn.Click += new EventHandler(strBtn_Click);

		//add string table item button
		Button strAddBtn = new Button();
		strAddBtn.Parent = gb;
		strAddBtn.Text = "&Add";
		strAddBtn.Width += 20;
		strAddBtn.Height -= 5;
		strAddBtn.Location = new Point(465, 60);
		strAddBtn.Anchor = AnchorStyles.Top | AnchorStyles.Right;
		strAddBtn.Click += new EventHandler(strAddBtn_Click);

		//remove string table item button
		Button strRemBtn = new Button();
		strRemBtn.Parent = gb;
		strRemBtn.Text = "&Remove";
		strRemBtn.Width += 20;
		strRemBtn.Height -= 5;
		strRemBtn.Location = new Point(465, 80);
		strRemBtn.Anchor = AnchorStyles.Top | AnchorStyles.Right;
		strRemBtn.Click += new EventHandler(strRemBtn_Click);

		//generate help button
		Button docBuild = new Button();
		docBuild.Parent = gb;
		docBuild.Text = "Generate &help";
		docBuild.Width += 20;
		docBuild.Height -= 5;
		docBuild.Location = new Point(465,100);
		docBuild.Anchor = AnchorStyles.Top | AnchorStyles.Right;
		docBuild.Visible = false;

		//generate ini button
		Button iniBuild = new Button();
		iniBuild.Parent = gb;
		iniBuild.Text = "Generate &ini";
		iniBuild.Width += 20;
		iniBuild.Height -= 5;
		iniBuild.Location = new Point(465,120);
		iniBuild.Anchor = AnchorStyles.Top | AnchorStyles.Right;
		iniBuild.Visible = false;

		//il groubbox
		gb = new GroupBox();
		gb.Parent = this;
		gb.Text = "IL code (double click to edit)";
		gb.Location = new Point(10, 385);
		gb.Size = new Size(570, 160);
		gb.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;

		//il listbox
		lb = new ListBox();
		lb.Parent = gb;
		lb.Location = new Point(10,15);
		lb.Size = new Size(550,140);
		lb.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
		lb.DoubleClick += new EventHandler(lb_DoubleClick);
	}