private void addFiles()
        {
            GWFunctions  gwf = new GWFunctions();
            DialogResult dresult;

            dresult = dgAddFiles.ShowDialog();
            if (dresult == DialogResult.OK)
            {
                for (int i = 0; i < dgAddFiles.FileNames.Length; i++)
                {
                    if (!FileInList(dgAddFiles.FileNames[i]))
                    {
                        ListViewItem lvi = new ListViewItem();
                        lvi = lstFiles.Items.Add(Path.GetFileName(dgAddFiles.FileNames[i]));
                        FileInfo f = new FileInfo(dgAddFiles.FileNames[i]);
                        lvi.SubItems.Add(filesizestring(f.Length));
                        lvi.SubItems.Add("RAW");
                        if (gwf.isGatewayDump(dgAddFiles.FileNames[i]))
                        {
                            lvi.SubItems[2].Text = "Gateway";
                        }
                        lvi.SubItems.Add(dgAddFiles.FileNames[i]);
                        resizeColumns();
                    }
                }
            }
        }
        private void viewSelectedPartitionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HeaderWindow newhrd = new HeaderWindow();
            GWFunctions  gwf    = new GWFunctions();

            newhrd.binfile = gwf.buildFromDump(lstFiles.SelectedItems[0].SubItems[3].Text);
            newhrd.Show();
        }
        private void pointerAddressSearchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <GWFileHeader> cheatFiles = new List <GWFileHeader>();
            GWFunctions         gwf        = new GWFunctions();
            string SHAmatch = null;
            bool   doMatch  = true;

            foreach (ListViewItem lvi in lstFiles.CheckedItems)
            {
                cheatFiles.Add(gwf.buildFromDump(lvi.SubItems[3].Text));
                if (SHAmatch == null)
                {
                    SHAmatch = cheatFiles[cheatFiles.Count - 1].headerSHA1;
                }
                else
                {
                    if (SHAmatch != cheatFiles[cheatFiles.Count - 1].headerSHA1)
                    {
                        doMatch = false;
                    }
                }
            }

            if ((cheatFiles.Count > 0) && doMatch)
            {
                PointerAddrWindow paddwin = new PointerAddrWindow();
                paddwin.ramDumps = cheatFiles;
                paddwin.Show();
            }
            else
            {
                if (!doMatch)
                {
                    MessageBox.Show("The layout of your RAM Dumps do not match. You cannot mix RAW/Gateway & all RAM dumps selected must be from the same game.", "Cheat Finder Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("You must have at least 1 RAM Dump ticked before searching.", "Cheat Finder Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void exportRAWRAMDumpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <GWFileHeader> heads = new List <GWFileHeader>();
            GWFunctions         gwf   = new GWFunctions();
            long tfSize   = 0;
            int  tregions = 0;

            foreach (ListViewItem lvi in lstFiles.CheckedItems)
            {
                if (lvi.SubItems[2].Text == "Gateway")
                {
                    heads.Add(gwf.buildFromDump(lvi.SubItems[3].Text));
                    tfSize   += heads[heads.Count - 1].rawsize;
                    tregions += heads[heads.Count - 1].memRegionCount;
                }
            }

            if (heads.Count > 0)
            {
                string plural = "s";
                if (heads.Count == 1)
                {
                    plural = "";
                }
                DialogResult confRes = MessageBox.Show(String.Format("Gateway RAM Tools will now create {0} RAW dump{1} totalling {2}.\r\nEach file will be in the same folder marked with '-raw'. Existing '-raw' files will be OVERWRITTEN.\r\n\r\nWould you like to continue?", heads.Count, plural, filesizestring(tfSize)), "Do You Want To Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (confRes == DialogResult.Yes)
                {
                    pbar.Value          = 0;
                    pbar.Maximum        = tregions;
                    pnlProgress.Visible = true;
                    exportRAWRAMDumpToolStripMenuItem.Enabled = false;
                    Thread backgroundThread = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < heads.Count; i++)
                        {
                            gwf.dumpGWRAM(heads[i], pbar);
                        }
                        pnlProgress.BeginInvoke(
                            new Action(() =>
                        {
                            pnlProgress.Visible = false;
                        }
                                       ));
                        menuStrip1.BeginInvoke(
                            new Action(() =>
                        {
                            exportRAWRAMDumpToolStripMenuItem.Enabled = true;
                        }
                                       ));
                        MessageBox.Show("RAM Dumps have been sucessfull created.", "RAW RAM Dumping", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                                        ));
                    backgroundThread.Start();
                }
            }
            else
            {
                MessageBox.Show("There are no Gateway RAM Dumps Ticked.", "No Gateway RAM TickedSelected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }