예제 #1
0
        private void menuLoadPCAP_Click(object sender, EventArgs e)
        {
            if (InputFileOpenDialog.ShowDialog() != DialogResult.OK)
                return;

            menuGenerateSQL.Enabled = false;
            menuPacketDump.Enabled = false;
            menuViewPackets.Enabled = false;
            menuDumpAAs.Enabled = false;

            SharpPcap.OfflinePcapDevice device;

            try
            {
                string CapFile = InputFileOpenDialog.FileName;

                device = new SharpPcap.OfflinePcapDevice(CapFile);

                device.Open();
            }
            catch
            {
                StatusBar.Text = "Error: File does not exist or not in .pcap format.";
                Log("Error: File does not exist or not in .pcap format.");
                return;
            }

            StreamProcessor = new EQStreamProcessor();

            if (!StreamProcessor.Init(Application.StartupPath, this.Log))
            {
                Log("Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.");
                StatusBar.Text = "Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.";
                return;
            }

            if (Options.EQPacketDebugFilename.Text.Length > 0)
            {
                try
                {
                    PacketDebugStream = new StreamWriter(Options.EQPacketDebugFilename.Text);
                    StreamProcessor.Packets.SetDebugLogHandler(PacketDebugLogger);
                }
                catch
                {
                    Log("Failed to open netcode debug file for writing.");
                    Options.EQPacketDebugFilename.Text = "";
                    StreamProcessor.Packets.SetDebugLogHandler(null);
                }
            }
            else
                StreamProcessor.Packets.SetDebugLogHandler(null);

            StatusBar.Text = "Reading packets from " + InputFileOpenDialog.FileName + ". Please wait...";

            device.OnPacketArrival +=
                new PacketArrivalEventHandler(device_OnPacketArrival);

            BytesRead = 0;
            PacketsSeen = 0;

            DebugLog.ConsoleWindow.Items.Add("-- Capturing from '" + InputFileOpenDialog.FileName);
            ProgressBar.Value = 0;
            ProgressBar.Show();

            menuFile.Enabled = false;

            CaptureFileSize = device.FileSize;

            device.Capture();

            device.Close();

            Log("End of file reached. Processed " + PacketsSeen + " packets and " + BytesRead + " bytes.");

            ProgressBar.Hide();

            if (Options.EQPacketDebugFilename.Text.Length > 0)
                PacketDebugStream.Close();

            PacketCountLabel.Text = PacketsSeen.ToString();
            if (StreamProcessor.Packets.ErrorsInStream)
                Log("There were errors encountered in the packet stream. Data may be incomplete.");

            DebugLog.ConsoleWindow.SelectedIndex = DebugLog.ConsoleWindow.Items.Count - 1;

            menuFile.Enabled = true;

            StreamProcessor.PCAPFileReadFinished();

            menuPacketDump.Enabled = true;

            menuViewPackets.Enabled = true;

            Log("Stream recognised as " + StreamProcessor.GetDecoderVersion());

            int PPLength = StreamProcessor.VerifyPlayerProfile();

            ClientVersionLabel.Text = StreamProcessor.GetDecoderVersion();

            if (PPLength == 0)
            {
                Log("Unable to find player profile packet, or packet not of correct size.");
                menuDumpAAs.Enabled = false;
                menuGenerateSQL.Enabled = false;
                ClientVersionLabel.ForeColor = Color.Red;
                ZoneLabel.Text = "";
                PacketCountLabel.Text = "";
                StatusBar.Text = "Unrecognised EQ Client Version. Press Ctrl-P to dump, or Ctrl-V to view packets.";
                return;
            }
            else
            {
                ClientVersionLabel.ForeColor = Color.Green;
                Log("Found player profile packet of the expected length (" + PPLength + ").");

                if(StreamProcessor.SupportsSQLGeneration())
                    StatusBar.Text = "Client version recognised. Press Ctrl-S to Generate SQL";
                else
                    StatusBar.Text = "Client version recognised. *SQL GENERATION NOT SUPPORTED FOR THIS CLIENT*";
            }

            ZoneName = StreamProcessor.GetZoneName();

            UInt32 ZoneNumber = StreamProcessor.GetZoneNumber();

            Log("Zonename is " + StreamProcessor.GetZoneName());

            Log("Zone number is " + ZoneNumber);

            ZoneLabel.Text = StreamProcessor.GetZoneLongName() + " [" + StreamProcessor.GetZoneName() + "] (" + ZoneNumber.ToString() + ")";

            SQLForm.ZoneIDTextBox.Text = ZoneNumber.ToString();
            SQLForm.ZoneIDTextBox.Enabled = true;
            SQLForm.DoorsTextBox.Enabled = true;
            SQLForm.NPCTypesTextBox.Enabled = true;
            SQLForm.SpawnEntryTextBox.Enabled = true;
            SQLForm.SpawnGroupTextBox.Enabled = true;
            SQLForm.Spawn2TextBox.Enabled = true;
            SQLForm.GridTextBox.Enabled = true;
            SQLForm.ObjectTextBox.Enabled = true;
            SQLForm.GroundSpawnTextBox.Enabled = true;
            SQLForm.MerchantTextBox.Enabled = true;
            SQLForm.VersionSelector.Enabled = true;
            menuGenerateSQL.Enabled = StreamProcessor.SupportsSQLGeneration();
            menuPacketDump.Enabled = true;
            menuViewPackets.Enabled = true;
            menuDumpAAs.Enabled = true;

            SQLForm.RecalculateBaseInsertIDs();

            StreamProcessor.GenerateZonePointList();
        }
예제 #2
0
        private void menuLoadPCAP_Click(object sender, EventArgs e)
        {
            if (InputFileOpenDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            menuGenerateSQL.Enabled = false;
            menuPacketDump.Enabled  = false;
            menuViewPackets.Enabled = false;
            menuDumpAAs.Enabled     = false;

            SharpPcap.OfflinePcapDevice device;

            try
            {
                string CapFile = InputFileOpenDialog.FileName;

                device = new SharpPcap.OfflinePcapDevice(CapFile);

                device.Open();
            }
            catch
            {
                StatusBar.Text = "Error: File does not exist or not in .pcap format.";
                Log("Error: File does not exist or not in .pcap format.");
                return;
            }

            StreamProcessor = new EQStreamProcessor();

            if (!StreamProcessor.Init(Application.StartupPath, this.Log))
            {
                Log("Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.");
                StatusBar.Text = "Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.";
                return;
            }

            if (Options.EQPacketDebugFilename.Text.Length > 0)
            {
                try
                {
                    PacketDebugStream = new StreamWriter(Options.EQPacketDebugFilename.Text);
                    StreamProcessor.Packets.SetDebugLogHandler(PacketDebugLogger);
                }
                catch
                {
                    Log("Failed to open netcode debug file for writing.");
                    Options.EQPacketDebugFilename.Text = "";
                    StreamProcessor.Packets.SetDebugLogHandler(null);
                }
            }
            else
            {
                StreamProcessor.Packets.SetDebugLogHandler(null);
            }

            StatusBar.Text = "Reading packets from " + InputFileOpenDialog.FileName + ". Please wait...";

            device.OnPacketArrival +=
                new PacketArrivalEventHandler(device_OnPacketArrival);

            BytesRead   = 0;
            PacketsSeen = 0;

            DebugLog.ConsoleWindow.Items.Add("-- Capturing from '" + InputFileOpenDialog.FileName);
            ProgressBar.Value = 0;
            ProgressBar.Show();

            menuFile.Enabled = false;

            CaptureFileSize = device.FileSize;

            device.Capture();

            device.Close();

            Log("End of file reached. Processed " + PacketsSeen + " packets and " + BytesRead + " bytes.");

            ProgressBar.Hide();

            if (Options.EQPacketDebugFilename.Text.Length > 0)
            {
                PacketDebugStream.Close();
            }

            PacketCountLabel.Text = PacketsSeen.ToString();
            if (StreamProcessor.Packets.ErrorsInStream)
            {
                Log("There were errors encountered in the packet stream. Data may be incomplete.");
            }

            DebugLog.ConsoleWindow.SelectedIndex = DebugLog.ConsoleWindow.Items.Count - 1;

            menuFile.Enabled = true;

            StreamProcessor.PCAPFileReadFinished();

            menuPacketDump.Enabled = true;

            menuViewPackets.Enabled = true;

            Log("Stream recognised as " + StreamProcessor.GetDecoderVersion());

            int PPLength = StreamProcessor.VerifyPlayerProfile();

            ClientVersionLabel.Text = StreamProcessor.GetDecoderVersion();

            if (PPLength == 0)
            {
                Log("Unable to find player profile packet, or packet not of correct size.");
                menuDumpAAs.Enabled          = false;
                menuGenerateSQL.Enabled      = false;
                ClientVersionLabel.ForeColor = Color.Red;
                ZoneLabel.Text        = "";
                PacketCountLabel.Text = "";
                StatusBar.Text        = "Unrecognised EQ Client Version. Press Ctrl-P to dump, or Ctrl-V to view packets.";
                return;
            }
            else
            {
                ClientVersionLabel.ForeColor = Color.Green;
                Log("Found player profile packet of the expected length (" + PPLength + ").");

                if (StreamProcessor.SupportsSQLGeneration())
                {
                    StatusBar.Text = "Client version recognised. Press Ctrl-S to Generate SQL";
                }
                else
                {
                    StatusBar.Text = "Client version recognised. *SQL GENERATION NOT SUPPORTED FOR THIS CLIENT*";
                }
            }

            ZoneName = StreamProcessor.GetZoneName();

            UInt32 ZoneNumber = StreamProcessor.GetZoneNumber();

            Log("Zonename is " + StreamProcessor.GetZoneName());

            Log("Zone number is " + ZoneNumber);

            ZoneLabel.Text = StreamProcessor.GetZoneLongName() + " [" + StreamProcessor.GetZoneName() + "] (" + ZoneNumber.ToString() + ")";

            SQLForm.ZoneIDTextBox.Text         = ZoneNumber.ToString();
            SQLForm.ZoneIDTextBox.Enabled      = true;
            SQLForm.DoorsTextBox.Enabled       = true;
            SQLForm.NPCTypesTextBox.Enabled    = true;
            SQLForm.SpawnEntryTextBox.Enabled  = true;
            SQLForm.SpawnGroupTextBox.Enabled  = true;
            SQLForm.Spawn2TextBox.Enabled      = true;
            SQLForm.GridTextBox.Enabled        = true;
            SQLForm.ObjectTextBox.Enabled      = true;
            SQLForm.GroundSpawnTextBox.Enabled = true;
            SQLForm.MerchantTextBox.Enabled    = true;
            SQLForm.VersionSelector.Enabled    = true;
            menuGenerateSQL.Enabled            = StreamProcessor.SupportsSQLGeneration();
            menuPacketDump.Enabled             = true;
            menuViewPackets.Enabled            = true;
            menuDumpAAs.Enabled = true;

            SQLForm.RecalculateBaseInsertIDs();

            StreamProcessor.GenerateZonePointList();
        }