private void btnImportMultis_Click(object sender, EventArgs e) { string inp = Microsoft.VisualBasic.Interaction.InputBox("Paste the raw, colon-delimited packet data here: ", "Enter packet data"); if (inp.Length == 0) { return; } inp = inp.Replace(":", ""); if (inp.Length % 2 != 0) { return; } inp = inp.Substring(4); byte[] data = new byte[inp.Length / 2]; for (int i = 0; i < inp.Length; i += 2) { data[i / 2] = Convert.ToByte(inp.Substring(i, 2), 16); } //no need to decrypt since it's init data OldPacket pkt = new OldPacket(data); pkt.Skip(3); txtDMulti.Text = pkt.GetByte().ToString(); txtEMulti.Text = pkt.GetByte().ToString(); _packetProcessActions.SetEncodeMultiples(pkt.Get()[5], pkt.Get()[6]); }
internal InProgressQuestData(OldPacket pkt) { _name = pkt.GetBreakString(); _description = pkt.GetBreakString(); _icon = (BookIcon)pkt.GetShort(); _progress = pkt.GetShort(); _target = pkt.GetShort(); if (pkt.GetByte() != 255) { throw new ArgumentException("Malformed quest packet", nameof(pkt)); } }
/// <summary> /// Handles SHOP_OPEN from server, contains shop data for a shop dialog /// </summary> private void _handleShopOpen(OldPacket pkt) { if (OnShopOpen == null) { return; } int shopKeeperID = pkt.GetShort(); string shopName = pkt.GetBreakString(); List <ShopItem> tradeItems = new List <ShopItem>(); while (pkt.PeekByte() != 255) { ShopItem nextItem = new ShopItem(pkt.GetShort(), pkt.GetThree(), pkt.GetThree(), pkt.GetChar()); tradeItems.Add(nextItem); } pkt.GetByte(); List <CraftItem> craftItems = new List <CraftItem>(); while (pkt.PeekByte() != 255) { int ID = pkt.GetShort(); List <Tuple <int, int> > ingreds = new List <Tuple <int, int> >(); for (int i = 0; i < 4; ++i) { ingreds.Add(new Tuple <int, int>(pkt.GetShort(), pkt.GetChar())); } craftItems.Add(new CraftItem(ID, ingreds)); } pkt.GetByte(); OnShopOpen(shopKeeperID, shopName, tradeItems, craftItems); }
private void _handleQuestDialog(OldPacket pkt) { if (OnQuestDialog == null) { return; } int numDialogs = pkt.GetChar(); short vendorID = pkt.GetShort(); short questID = pkt.GetShort(); short sessionID = pkt.GetShort(); //not used by eoserv short dialogID = pkt.GetShort(); //not used by eoserv if (pkt.GetByte() != 255) { return; } QuestState stateInfo = new QuestState(sessionID, dialogID, questID, vendorID); var dialogNames = new Dictionary <short, string>(numDialogs); for (int i = 0; i < numDialogs; ++i) { dialogNames.Add(pkt.GetShort(), pkt.GetBreakString()); } var pages = new List <string>(); var links = new Dictionary <short, string>(); while (pkt.ReadPos != pkt.Length) { var entry = (DialogEntry)pkt.GetShort(); switch (entry) { case DialogEntry.DialogText: pages.Add(pkt.GetBreakString()); break; case DialogEntry.DialogLink: links.Add(pkt.GetShort(), pkt.GetBreakString()); break; } } OnQuestDialog(stateInfo, dialogNames, pages, links); }
private void _handlePlayerList(OldPacket pkt, bool isFriendList) { short numTotal = pkt.GetShort(); if (pkt.GetByte() != 255) { return; } m_init_onlinePlayerList = new List <OnlineEntry>(); for (int i = 0; i < numTotal; ++i) { string name = pkt.GetBreakString(); if (!isFriendList) { string title = pkt.GetBreakString(); if (string.IsNullOrWhiteSpace(title)) { title = "-"; } if (pkt.GetChar() != 0) { return; } PaperdollIconType iconType = (PaperdollIconType)pkt.GetChar(); int clsId = pkt.GetChar(); string guild = pkt.GetBreakString(); if (string.IsNullOrWhiteSpace(guild)) { guild = "-"; } name = char.ToUpper(name[0]) + name.Substring(1); title = char.ToUpper(title[0]) + title.Substring(1); m_init_onlinePlayerList.Add(new OnlineEntry(name, title, guild, clsId, iconType)); } else { m_init_onlinePlayerList.Add(new OnlineEntry(name, "", "", 0, PaperdollIconType.Normal)); } } }
public override void OnInstalled() { while (!this.Initialized) { foreach (var window in OpenWindowGetter.GetOpenWindows()) { var handle = window.Key; var title = window.Value; if (title.StartsWith("Endless Online")) { this.Initialized = true; this.EndlessHandle = handle; this.EndlessTitle = title; } } Thread.Sleep(100); } this.EOPacketManager = new EOPacketManager(this); this.NetworkDetour = new NetworkDetour().Install(PacketChannel.Send | PacketChannel.WSARecv, new InterceptCallback((packet) => { if (packet.Destination.Port == 8076 || packet.Destination.Port == 0) { return(new InterceptResponse(false)); } if (!this.EOPacketInit) { if (packet.Channel == PacketChannel.WSARecv) { var decode = new OldPacket(packet.Buffer.Skip(2)); if (decode.Family != PacketFamily.Init || decode.Action != PacketAction.Init) { return(new InterceptResponse(false)); } this.EOPacketInit = true; decode.Skip(3); this.EOPacketManager.SetMultiples(decode.GetByte(), decode.GetByte()); } return(new InterceptResponse(false)); } var channel = packet.Channel == PacketChannel.Send ? EOPacketChannel.Send : EOPacketChannel.Receive; this.EOPacketManager.HandlePacket(channel, packet.Buffer.Skip(2)); return(new InterceptResponse(false)); })); Thread.Sleep(1000); EasyTimer.SetInterval(() => { if (this.IsMovingWindow) { RepositionMarketWindow(); } }, 16); EasyTimer.SetInterval(() => { if (Program.Market.Visible) { SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); RepositionMarketWindow(); } }, 5000); Program.Market.Load += (s, e) => { var threadId = GetWindowThreadProcessId(this.EndlessHandle, out var processId); this.CBTCallback = this.CBT_Callback; this.CBTHook = SetWindowsHookEx(HookType.WH_CBT, CBTCallback, instancePtr: IntPtr.Zero, threadID: threadId); SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); RepositionMarketWindow(); }; Program.Market.Shown += (s, e) => { SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); RepositionMarketWindow(); }; Program.Market.VisibleChanged += (s, e) => { if (Program.Market.Visible) { SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); RepositionMarketWindow(); } }; Program.Market.Hide(); Application.EnableVisualStyles(); new Thread(() => { Application.Run(); }).Start(); }
private void _handleInitInit(OldPacket pkt) { InitReply response = (InitReply)pkt.GetByte(); switch (response) { case InitReply.INIT_FRIEND_LIST_PLAYERS: case InitReply.INIT_PLAYERS: if (!m_client.ExpectingPlayerList) { break; } _handlePlayerList(pkt, response == InitReply.INIT_FRIEND_LIST_PLAYERS); break; case InitReply.INIT_MAP_MUTATION: { string localDir = response == InitReply.INIT_FILE_MAP || response == InitReply.INIT_MAP_MUTATION ? "maps" : "pub"; if (response == InitReply.INIT_MAP_MUTATION) { m_init_requestedMap = 0; } if (!Directory.Exists(localDir)) { Directory.CreateDirectory(localDir); } string filename; if (response == InitReply.INIT_FILE_EIF) { filename = "dat001.eif"; } else if (response == InitReply.INIT_FILE_ENF) { filename = "dtn001.enf"; } else if (response == InitReply.INIT_FILE_ESF) { filename = "dsl001.esf"; } else if (response == InitReply.INIT_FILE_ECF) { filename = "dat001.ecf"; } else { filename = $"{m_init_requestedMap,5:D5}.emf"; } using (FileStream fs = File.Create(Path.Combine(localDir, filename))) { int dataLen = pkt.Length - 3; if (dataLen == 0) { return; //trigger error by not setting response event } fs.Write(pkt.GetBytes(dataLen), 0, dataLen); } if (response == InitReply.INIT_MAP_MUTATION && OnMapMutation != null) { OnMapMutation(); } } break; } m_client.ExpectingFile = false; m_client.ExpectingPlayerList = false; m_init_responseEvent.Set(); //packet was handled }