├── PacketSenderPlz ├── stdafx.cpp ├── stdafx.h ├── packet.h ├── PacketSenderPlz.vcxproj.filters ├── packet.cpp ├── MapleStructs.h ├── EntryPoint.cpp └── PacketSenderPlz.vcxproj ├── .gitattributes ├── PacketSenderPlz.sln ├── LICENSE ├── README.md └── .gitignore /PacketSenderPlz/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" -------------------------------------------------------------------------------- /PacketSenderPlz/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /PacketSenderPlz/packet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class packet 4 | { 5 | std::string error_; 6 | std::string source_; 7 | std::vector data_; 8 | bool should_be_parsed_; 9 | 10 | static uint32_t main_thread_id_; 11 | 12 | template 13 | void encode(T data); 14 | 15 | public: 16 | packet(); 17 | packet(uint16_t header); 18 | bool is_connected(); 19 | 20 | void encode1(uint8_t data); 21 | void encode2(uint16_t data); 22 | void encode4(uint32_t data); 23 | void encode8(uint64_t data); 24 | void encode_string(std::string data); 25 | void encode_data(std::initializer_list data); 26 | 27 | bool parse(std::string& source); 28 | bool receive(); 29 | bool send(); 30 | 31 | std::string to_string(); 32 | std::string get_error(); 33 | }; 34 | -------------------------------------------------------------------------------- /PacketSenderPlz.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PacketSenderPlz", "PacketSenderPlz\PacketSenderPlz.vcxproj", "{8CCB7E31-4089-4F86-86D4-A61CF253BD3E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8CCB7E31-4089-4F86-86D4-A61CF253BD3E}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {8CCB7E31-4089-4F86-86D4-A61CF253BD3E}.Debug|Win32.Build.0 = Debug|Win32 16 | {8CCB7E31-4089-4F86-86D4-A61CF253BD3E}.Release|Win32.ActiveCfg = Release|Win32 17 | {8CCB7E31-4089-4F86-86D4-A61CF253BD3E}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Waty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PacketSenderPlz 2 | A simple bypassless packetsender for Europe MapleStory 3 | 4 | ## Updating 5 | * Open **MapleStructs.h** 6 | * The second line of the file is **#define EMS**, change it to GMS if that's what you're compiling for 7 | * Update the addys in the correct namespace to the new version using the AOBs provided, and change the **GameVersion** to the version you're compiling for. 8 | 9 | PacketSenderPlz should now be updated to the version you want to use it in. 10 | 11 | (There are plans to make it update automatically, but for now you'll have to do it manually :wink:) 12 | 13 | ## Compiling 14 | PacketSenderPlz uses nana as UI toolkit, so you will need to configure that before you're gonna be able to compile the code 15 | 16 | Thankfully, nana is included in the [vcpkg](https://github.com/Microsoft/vcpkg/) project from Microsoft, making installation easier then ever: 17 | * Install [vcpkg](https://github.com/Microsoft/vcpkg/) by following the instructions in their README.md 18 | * Let vcpkg download, configure and compile nana for you by executing `.\vcpkg install nana:x86-windows-static` 19 | 20 | That's it :smiley: PacketSenderPlz should now compile correctly 21 | -------------------------------------------------------------------------------- /PacketSenderPlz/PacketSenderPlz.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | .vs/ 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /PacketSenderPlz/packet.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "packet.h" 3 | #include "MapleStructs.h" 4 | 5 | extern void log(const std::string& message); 6 | 7 | packet::packet() : should_be_parsed_(false) {} 8 | 9 | packet::packet(uint16_t header) : packet() 10 | { 11 | encode2(header); 12 | } 13 | 14 | void packet::encode1(uint8_t data) 15 | { 16 | return encode(data); 17 | } 18 | 19 | void packet::encode2(uint16_t data) 20 | { 21 | return encode(data); 22 | } 23 | 24 | void packet::encode4(uint32_t data) 25 | { 26 | return encode(data); 27 | } 28 | 29 | void packet::encode8(uint64_t data) 30 | { 31 | return encode(data); 32 | } 33 | 34 | void packet::encode_string(std::string data) 35 | { 36 | encode2(static_cast(data.size())); 37 | data_.insert(data_.end(), data.begin(), data.end()); 38 | } 39 | 40 | void packet::encode_data(std::initializer_list data) 41 | { 42 | data_.insert(data_.end(), data.begin(), data.end()); 43 | } 44 | 45 | template 46 | void packet::encode(T data) 47 | { 48 | auto ptr = reinterpret_cast(&data); 49 | data_.insert(data_.end(), ptr, ptr + sizeof(T)); 50 | } 51 | 52 | bool packet::is_connected() 53 | { 54 | try 55 | { 56 | return *reinterpret_cast(CClientSocketPtr) != nullptr; 57 | } 58 | catch (...) 59 | { 60 | return false; 61 | } 62 | } 63 | 64 | bool packet::parse(std::string& data) 65 | { 66 | source_ = data; 67 | //Removing all spaces from the packet 68 | source_.erase(remove(source_.begin(), source_.end(), ' '), source_.end()); 69 | if (source_.size() % 2 != 0) 70 | { 71 | error_ = "The total length of the packet was not an even number.\n" 72 | "Because I'm lazy, the parser isn't able to understand that you mean '0F' when you type 'F', " 73 | "so please prefix all small bytes with a 0.\n"; 74 | return false; 75 | } 76 | 77 | if (source_.size() == 0) 78 | { 79 | error_ = "The input string didn't contain a single valid hexadecimal byte...\n"; 80 | return false; 81 | } 82 | 83 | data_.clear(); 84 | data_.reserve(source_.size() / 2); 85 | should_be_parsed_ = false; 86 | for (int i = 0, size = source_.size(); i < size; i += 2) 87 | { 88 | char c1 = source_[i]; 89 | char c2 = source_[i + 1]; 90 | 91 | auto is_valid_byte = [this](char& c) 92 | { 93 | if (!isxdigit(c)) 94 | { 95 | std::stringstream ss; 96 | if (c == '?' || c == '*') 97 | { 98 | //The packet contains random bytes so we need to do the parsing every time we send the packet 99 | should_be_parsed_ = true; 100 | ss << std::uppercase << std::hex << rand() % 0xF; 101 | ss >> c; 102 | } 103 | else 104 | { 105 | ss << std::uppercase << std::hex << c; 106 | error_ = "It contained an invalid character: " + ss.str(); 107 | return false; 108 | } 109 | } 110 | return true; 111 | }; 112 | 113 | if (is_valid_byte(c1) && is_valid_byte(c2)) 114 | { 115 | int b; 116 | std::stringstream ss; 117 | ss << std::hex << c1 << c2; 118 | ss >> b; 119 | data_.push_back(b); 120 | } 121 | else return false; 122 | } 123 | return true; 124 | } 125 | 126 | bool packet::receive() 127 | { 128 | error_ = "Not implemented :-("; 129 | return false; 130 | } 131 | 132 | bool packet::send() 133 | { 134 | if (should_be_parsed_ && !parse(source_)) return false; 135 | 136 | #ifdef _DEBUG 137 | 138 | log("Sent " + to_string()); 139 | return true; 140 | #else 141 | 142 | //The packet needs to have atleast the header if we want to send it 143 | if (!is_connected()) 144 | { 145 | error_ = "CClientSocket isn't connected\n" 146 | "You are probably hitting the Send button at the play screen, or MS just crashed..."; 147 | return false; 148 | } 149 | 150 | COutPacket p; 151 | p.m_lpvSendBuff = &data_[0]; 152 | p.m_uDataLen = data_.size(); 153 | 154 | try { (*reinterpret_cast(CClientSocketPtr))->SendPacket(p); return true; } 155 | catch (...) { return false; } 156 | #endif 157 | } 158 | 159 | std::string packet::to_string() 160 | { 161 | std::stringstream ss; 162 | ss << std::uppercase << std::hex; 163 | for (uint8_t b : data_) ss << std::setw(2) << std::setfill('0') << static_cast(b) << ' '; 164 | 165 | std::string result = ss.str(); 166 | result.pop_back(); 167 | return result; 168 | } 169 | 170 | std::string packet::get_error() 171 | { 172 | return error_; 173 | } 174 | 175 | uint32_t packet::main_thread_id_ = 0; 176 | -------------------------------------------------------------------------------- /PacketSenderPlz/MapleStructs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | const uint32_t GameVersion = 183; 4 | const uint32_t MSLockAddy = 0x5E5210; // 55 8B EC 56 8B 75 08 57 8B F9 5 | const uint32_t MSUnlockAddy = 0x60B790; // 8B 01 83 40 04 FF 75 06 6 | const uint32_t innoHashAddy = 0xBEAAE0; // 55 8B EC 51 8B 4D 10 8D 45 7 | const uint32_t FlushSocketAddy = 0xDC7150; // 55 8B EC 6A FF 68 48 8C 2F 02 64 A1 00 00 00 00 50 83 EC 18 A1 E8 58 AC 02 33 C5 50 8 | const uint32_t MakeBufferListAddy = 0x9BB2E0; // 55 8B EC 6A FF 68 A8 B3 29 02 64 A1 00 00 00 00 50 83 EC 1C 53 56 57 A1 E8 58 AC 02 33 C5 50 8D 45 F4 64 A3 00 00 00 00 89 4D E8 8B 41 08 3D 00 FF 00 00 8D 50 9 | const uint32_t CClientSocketPtr = 0x2AF17B4; // 8B 0D ? ? ? ? 85 ? 74 ? 8D ? ? ? ? ? ? 19 00 10 | 11 | 12 | struct ZSocketBase 13 | { 14 | unsigned int _m_hSocket; 15 | }; 16 | 17 | template 18 | struct ZList 19 | { 20 | virtual ~ZList() = delete; 21 | void* baseclass_4; 22 | unsigned int _m_uCount; 23 | T* _m_pHead; 24 | T* _m_pTail; 25 | }; 26 | 27 | static_assert(sizeof(ZList) == 0x14, "ZList is the wrong size"); 28 | 29 | template 30 | struct ZRef 31 | { 32 | void* vfptr; 33 | T* data; 34 | }; 35 | 36 | #pragma pack( push, 1 ) 37 | struct COutPacket 38 | { 39 | COutPacket() : m_bLoopback(false), m_lpvSendBuff(nullptr), m_uDataLen(0), m_uOffset(0), m_bIsEncryptedByShanda(false) 40 | { 41 | } 42 | 43 | COutPacket(unsigned char* data, unsigned int dwLength) : COutPacket() 44 | { 45 | m_lpvSendBuff = data; 46 | m_uDataLen = dwLength; 47 | } 48 | 49 | bool m_bLoopback; // + 0x00 50 | unsigned char* m_lpvSendBuff; // + 0x04 51 | unsigned int m_uDataLen; // + 0x08 52 | unsigned int m_uOffset; // + 0x0C 53 | bool m_bIsEncryptedByShanda; // + 0x10 54 | 55 | void MakeBufferList(ZList>* l, unsigned __int16 uSeqBase, unsigned int* puSeqKey, int bEnc, unsigned int dwKey) 56 | { 57 | typedef void(__thiscall *MakeBufferList_t)(COutPacket* _this, ZList>* l, unsigned __int16 uSeqBase, unsigned int* puSeqKey, int bEnc, unsigned int dwKey); 58 | MakeBufferList_t MakeBufferList = reinterpret_cast(MakeBufferListAddy); 59 | MakeBufferList(this, l, uSeqBase, puSeqKey, bEnc, dwKey); 60 | } 61 | }; 62 | 63 | struct CInPacket 64 | { 65 | bool m_bLoopback; // + 0x00 66 | int m_nState; // + 0x04 67 | unsigned char* m_lpbRecvBuff; // + 0x08 68 | unsigned int m_uLength; // + 0x0C 69 | unsigned int m_uRawSeq; // + 0x10 70 | unsigned int m_uDataLen; // + 0x14 71 | unsigned int m_uOffset; // + 0x18 72 | }; 73 | 74 | #pragma pack( pop ) 75 | 76 | struct ZFatalSectionData 77 | { 78 | void* _m_pTIB; // + 0x00 79 | int _m_nRef; // + 0x04 80 | }; 81 | 82 | struct ZFatalSection : ZFatalSectionData 83 | { 84 | }; 85 | 86 | template 87 | struct ZSynchronizedHelper 88 | { 89 | explicit __inline ZSynchronizedHelper(T* lock) 90 | { 91 | reinterpret_cast*, T*)>(MSLockAddy)(this, lock); 92 | } 93 | 94 | __inline ~ZSynchronizedHelper() 95 | { 96 | reinterpret_cast*)>(MSUnlockAddy)(this); 97 | } 98 | 99 | private: 100 | T* m_pLock; 101 | }; 102 | 103 | static auto CIGCipher__innoHash = reinterpret_cast(innoHashAddy); 104 | struct CClientSocket 105 | { 106 | struct CONNECTCONTEXT 107 | { 108 | ZList lAddr; 109 | void* posList; 110 | int bLogin; 111 | 112 | ~CONNECTCONTEXT() = delete; 113 | }; 114 | 115 | virtual ~CClientSocket() = delete; 116 | void* _unknown1; 117 | HWND* m_hWnd; 118 | ZSocketBase m_sock; 119 | CONNECTCONTEXT m_ctxConnect; 120 | sockaddr_in m_addr; 121 | int m_tTimeout; 122 | void* _unknown2; 123 | ZList> m_lpRecvBuff; //ZList > 124 | ZList> m_lpSendBuff; //ZList > 125 | CInPacket m_packetRecv; 126 | ZFatalSection m_lockSend; 127 | unsigned int m_uSeqSnd; 128 | unsigned int m_uSeqRcv; 129 | 130 | void Flush() 131 | { 132 | reinterpret_cast(FlushSocketAddy)(this); 133 | } 134 | 135 | void SendPacket(COutPacket& oPacket) 136 | { 137 | ZSynchronizedHelper lock(&m_lockSend); 138 | 139 | if (m_sock._m_hSocket != 0 && m_sock._m_hSocket != 0xFFFFFFFF && m_ctxConnect.lAddr._m_uCount == 0) 140 | { 141 | oPacket.MakeBufferList(&m_lpSendBuff, GameVersion, &m_uSeqSnd, 1, m_uSeqSnd); 142 | m_uSeqSnd = CIGCipher__innoHash(reinterpret_cast(&m_uSeqSnd), 4, nullptr); 143 | Flush(); 144 | } 145 | } 146 | }; 147 | 148 | static_assert(sizeof(CClientSocket) == 0x98, "CClientSocket is the wrong size!"); 149 | -------------------------------------------------------------------------------- /PacketSenderPlz/EntryPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "packet.h" 3 | 4 | using namespace nana; 5 | using namespace threads; 6 | 7 | HINSTANCE instance_handle; 8 | int send_count = 0, line_delay = 0, loop_delay = 0; 9 | std::atomic cancelled; 10 | 11 | void log(const std::string& message) 12 | { 13 | #ifdef _DEBUG 14 | HWND handle = GetConsoleWindow(); 15 | if (handle == nullptr) 16 | { 17 | AllocConsole(); 18 | FILE* stream; 19 | freopen_s(&stream, "CONOUT$", "w", stdout); 20 | freopen_s(&stream, "CONIN$", "r", stdin); 21 | } 22 | else ShowWindow(handle, SW_SHOW); 23 | std::cout << message << '\n'; 24 | #else 25 | MessageBoxA(nullptr, message.c_str(), nullptr, 0); 26 | #endif 27 | } 28 | 29 | void on_unload(const arg_unload& info) 30 | { 31 | msgbox box(info.window_handle, "Close MS?", msgbox::button_t::yes_no_cancel); 32 | box.icon(msgbox::icon_t::icon_question) << "Do you want to close MapleStory too?"; 33 | switch (box.show()) 34 | { 35 | case msgbox::pick_yes: 36 | TerminateProcess(GetCurrentProcess(), EXIT_SUCCESS); 37 | break; 38 | 39 | case msgbox::pick_no: 40 | FreeLibraryAndExitThread(instance_handle, EXIT_SUCCESS); 41 | 42 | default: 43 | case msgbox::pick_cancel: 44 | info.cancel = true; 45 | break; 46 | } 47 | } 48 | 49 | void send_all_lines(const std::vector& lines) 50 | { 51 | packet p; 52 | 53 | for (auto str : lines) 54 | { 55 | if (cancelled) break; 56 | if (!p.parse(str) || !p.send()) 57 | { 58 | cancelled = true; 59 | log(p.get_error()); 60 | } 61 | 62 | std::this_thread::sleep_for(std::chrono::milliseconds(line_delay)); 63 | } 64 | } 65 | 66 | void send_packets(const std::vector& lines, progress& progressbar) 67 | { 68 | #ifdef _DEBUG 69 | log("Sending " + std::to_string(lines.size()) + " packets " + std::to_string(send_count) + " times"); 70 | #endif 71 | 72 | cancelled = false; 73 | if (send_count > 0) 74 | { 75 | progressbar.unknown(false); 76 | progressbar.amount(send_count); 77 | for (int times_sent = 0; times_sent < send_count; times_sent++) 78 | { 79 | if (cancelled) break; 80 | progressbar.value(times_sent); 81 | send_all_lines(lines); 82 | std::this_thread::sleep_for(std::chrono::milliseconds(loop_delay)); 83 | } 84 | } 85 | else 86 | { 87 | progressbar.unknown(true); 88 | while (!cancelled) 89 | { 90 | progressbar.inc(); 91 | send_all_lines(lines); 92 | std::this_thread::sleep_for(std::chrono::milliseconds(loop_delay)); 93 | } 94 | } 95 | } 96 | 97 | DWORD WINAPI start(LPVOID /*lpInstance*/) 98 | { 99 | form fm; 100 | fm.caption(u8"Waty's PacketSenderPlz v2.4"); 101 | fm.events().unload(on_unload); 102 | 103 | //Initialize all controls: 104 | place plc(fm); 105 | progress progressbar(fm); 106 | textbox tbPackets(fm), tbSendCount(fm), tbLineDelay(fm), tbLoopDelay(fm); 107 | button bSend(fm, "Send"), bCancel(fm, "Cancel"); 108 | pool thrpool(1); 109 | 110 | tbPackets.set_accept([](wchar_t c) { return iswxdigit(c) || iswcntrl(c) || c == '*' || c == ' '; }); 111 | API::eat_tabstop(tbPackets, false); 112 | 113 | auto filter = [](wchar_t c) { return iswdigit(c) || iswcntrl(c); }; 114 | tbSendCount.tip_string("SendCount").multi_lines(false); 115 | tbSendCount.tooltip("Specifies how many times this packet will be sent."); 116 | tbSendCount.set_accept(filter); 117 | API::eat_tabstop(tbSendCount, false); 118 | 119 | tbLineDelay.tip_string("LineDelay").multi_lines(false); 120 | tbLineDelay.tooltip("Specifies the delay in milliseconds that the sender will wait before sending the next line"); 121 | tbLineDelay.set_accept(filter); 122 | API::eat_tabstop(tbLineDelay, false); 123 | 124 | tbLoopDelay.tip_string("LoopDelay").multi_lines(false); 125 | tbLoopDelay.tooltip("The delay in milliseconds that the sender will wait before restarting the loop"); 126 | tbLoopDelay.set_accept(filter); 127 | API::eat_tabstop(tbLoopDelay, false); 128 | 129 | auto show_progress = [&](bool show) 130 | { 131 | plc.field_display("controls", !show); 132 | plc.field_display("progress", show); 133 | plc.collocate(); 134 | }; 135 | 136 | bSend.events().click([&] 137 | { 138 | thrpool.push([&] 139 | { 140 | show_progress(true); 141 | 142 | send_count = tbSendCount.to_int(); 143 | line_delay = tbLineDelay.to_int(); 144 | loop_delay = tbLoopDelay.to_int(); 145 | 146 | std::vector lines; 147 | std::string str; 148 | for (size_t i = 0; tbPackets.getline(i, str); i++) lines.push_back(str); 149 | send_packets(lines, progressbar); 150 | 151 | show_progress(false); 152 | }); 153 | }); 154 | bCancel.events().click([] { cancelled = true; }); 155 | 156 | //place the widgets in the correct fields 157 | plc.div(" > >"); 158 | plc.field("packets") << tbPackets; 159 | plc.field("progress") << progressbar << bCancel; 160 | plc.field("controls") << tbSendCount << tbLineDelay << tbLoopDelay << bSend; 161 | show_progress(false); 162 | 163 | fm.show(); 164 | exec(); 165 | 166 | return EXIT_SUCCESS; 167 | } 168 | 169 | int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/) 170 | { 171 | start(hInstance); 172 | } 173 | 174 | BOOL WINAPI DllMain(HMODULE module, DWORD fdwReason, LPVOID /*lpvReserved*/) 175 | { 176 | if (fdwReason == DLL_PROCESS_ATTACH) 177 | CreateThread(nullptr, NULL, start, module, NULL, nullptr); 178 | 179 | return TRUE; 180 | } 181 | -------------------------------------------------------------------------------- /PacketSenderPlz/PacketSenderPlz.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {8CCB7E31-4089-4F86-86D4-A61CF253BD3E} 15 | Win32Proj 16 | PacketSenderPlz 17 | 18 | x86-windows-static 19 | true 20 | 21 | 22 | 23 | Application 24 | true 25 | v141 26 | Unicode 27 | 28 | 29 | DynamicLibrary 30 | false 31 | v141 32 | true 33 | Unicode 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | .exe 48 | 49 | 50 | false 51 | 52 | 53 | 54 | Use 55 | Level3 56 | Disabled 57 | WIN32;_DEBUG;_WINDOWS;_USRDLL;PACKETSENDERPLZ_EXPORTS;%(PreprocessorDefinitions) 58 | true 59 | ProgramDatabase 60 | MultiThreadedDebug 61 | 62 | 63 | Windows 64 | true 65 | 66 | 67 | 68 | 69 | Level3 70 | Use 71 | MaxSpeed 72 | true 73 | true 74 | WIN32;NDEBUG;_WINDOWS;_USRDLL;PACKETSENDERPLZ_EXPORTS;%(PreprocessorDefinitions) 75 | true 76 | MultiThreaded 77 | 78 | 79 | Windows 80 | true 81 | true 82 | true 83 | 84 | 85 | 86 | 87 | 88 | 89 | Create 90 | Create 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | --------------------------------------------------------------------------------