├── .gitattributes ├── .gitignore ├── Block-SpamMessage.sln ├── Block-SpamMessage ├── Block-SpamMessage.vcxproj ├── Block-SpamMessage.vcxproj.filters ├── dllmain.cpp ├── framework.h ├── minhook │ ├── minhook.h │ └── minhook.lib ├── pch.cpp ├── pch.h ├── sigscan.cpp └── sigscan.h ├── README.md └── example.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Block-SpamMessage.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Block-SpamMessage", "Block-SpamMessage\Block-SpamMessage.vcxproj", "{55A6C981-FBF0-4088-A016-B805C8A2A6A0}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Debug|x64.ActiveCfg = Debug|x64 17 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Debug|x64.Build.0 = Debug|x64 18 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Debug|x86.ActiveCfg = Debug|Win32 19 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Debug|x86.Build.0 = Debug|Win32 20 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Release|x64.ActiveCfg = Release|x64 21 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Release|x64.Build.0 = Release|x64 22 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Release|x86.ActiveCfg = Release|Win32 23 | {55A6C981-FBF0-4088-A016-B805C8A2A6A0}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {4D4CB075-C64E-4A43-8B62-41C8DE9C12F0} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Block-SpamMessage/Block-SpamMessage.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {55a6c981-fbf0-4088-a016-b805c8a2a6a0} 25 | BlockSpamMessage 26 | 10.0 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | DynamicLibrary 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | minhook;$(LibraryPath) 85 | 86 | 87 | 88 | Level3 89 | true 90 | WIN32;_DEBUG;BLOCKSPAMMESSAGE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 91 | true 92 | Use 93 | pch.h 94 | 95 | 96 | Windows 97 | true 98 | false 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | true 106 | true 107 | WIN32;NDEBUG;BLOCKSPAMMESSAGE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 108 | true 109 | Use 110 | pch.h 111 | 112 | 113 | Windows 114 | true 115 | true 116 | true 117 | false 118 | 119 | 120 | 121 | 122 | Level3 123 | true 124 | _DEBUG;BLOCKSPAMMESSAGE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 125 | true 126 | Use 127 | pch.h 128 | 129 | 130 | Windows 131 | true 132 | false 133 | 134 | 135 | 136 | 137 | Level3 138 | true 139 | true 140 | true 141 | NDEBUG;BLOCKSPAMMESSAGE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 142 | true 143 | Use 144 | pch.h 145 | stdcpp17 146 | 147 | 148 | Windows 149 | true 150 | true 151 | true 152 | false 153 | minhook.lib;%(AdditionalDependencies) 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | Create 165 | Create 166 | Create 167 | Create 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /Block-SpamMessage/Block-SpamMessage.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 29 | 30 | 源文件 31 | 32 | 33 | 源文件 34 | 35 | 36 | 源文件 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Block-SpamMessage/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "minhook/minhook.h" 3 | #include "sigscan.h" 4 | 5 | bool g_running = true; 6 | bool IsSpam(std::string message) { 7 | const char* words[] = {"~", "font", "外挂", "群", "刷", "VX", "微", "解锁", "辅助", "淘宝", "卡网", "科技", "成人", "少妇", "萝莉", "淫", "少女", "片", "官网", "www", "WWW", "xyz", "top", "cn", "QQ", "qq", "激情"}; 8 | for (int i = 0; i < 27; i++) 9 | { 10 | if (strstr(message.c_str(), words[i]) != NULL) 11 | return true; 12 | } 13 | return false; 14 | } 15 | 16 | class CEventNetWorkTextMessageReceived 17 | { 18 | public: 19 | char pad_0000[24]; //0x0000 20 | char m_info[8]; //0x0018 21 | char pad_0020[36]; //0x0020 22 | }; //Size: 0x0044 23 | using event_network_text_message_received_t = char __fastcall (CEventNetWorkTextMessageReceived* a1, DWORD64* a2, int a3); 24 | typedef __int64(__cdecl* get_chat_data_t)(__int64 a1, __int64 a2, __int64 a3, const char* receivetext, BOOL a5); 25 | event_network_text_message_received_t* m_event_network_text_message_received{}; 26 | get_chat_data_t m_get_chat_data{}; 27 | 28 | get_chat_data_t og_get_chat_data = nullptr; 29 | __int64 __cdecl hk_get_chat_data(__int64 a1, __int64 a2, __int64 a3, const char* receivetext, BOOL a5) 30 | { 31 | bool isspam = IsSpam(receivetext); 32 | if (isspam) 33 | return 0; 34 | 35 | return og_get_chat_data(a1, a2, a3, receivetext, a5); 36 | } 37 | 38 | event_network_text_message_received_t* og_event_network_text_message_received = nullptr; 39 | bool hk_event_network_text_message_received(CEventNetWorkTextMessageReceived* a1, DWORD64* a2, int a3) 40 | { 41 | bool isspam = IsSpam(a1->m_info); 42 | if (isspam) 43 | return false; 44 | return og_event_network_text_message_received(a1, a2, a3); 45 | } 46 | 47 | void* og_presence_bounty = nullptr; 48 | PVOID m_presence_bounty{}; 49 | bool hk_presence_bounty(__int64 a1, __int64 a2) 50 | { 51 | return false; 52 | } 53 | 54 | DWORD Mainthread(LPVOID lp) 55 | { 56 | MH_Initialize(); 57 | 58 | pattern_batch main_batch; 59 | main_batch.add("EventNetWorkTextMessageReceived", "48 83 EC 28 4C 8B CA 48 85 D2 0F 84 ? ? ? ? 41 BA ? ? ? ? 45 3B C2 0F 85 ? ? ? ? 48 8D 51 18 48 8B C2 49 0B C1 83 E0 0F 0F 85 ? ? ? ? B8 ? ? ? ? 8D 48 7F 0F 28 02 41 0F 29 01 0F 28 4A 10 41 0F 29 49 ? 0F 28 42 20 41 0F 29 41 ? 0F 28 4A 30 41 0F 29 49 ? 0F 28 42 40 41 0F 29 41 ? 0F 28 4A 50 41 0F 29 49 ? 0F 28 42 60 41 0F 29 41 ? 0F 28 4A 70 4C 03 C9 48 03 D1 41 0F 29 49 ? 48 FF C8 75 AF 0F 28 02 41 0F 29 01 0F 28 4A 10 41 0F 29 49 ? 0F 28 42 20 41 0F 29 41 ? 0F 28 4A 30 41 0F 29 49 ? 0F 28 42 40 41 0F 29 41 ? 0F 28 4A 50 41 0F 29 49 ? 48 8B 42 60", [=](ptr_manage ptr) 60 | { 61 | m_event_network_text_message_received = ptr.as(); 62 | }); 63 | main_batch.add("get_chat_data", "49 8B C1 45 33 C9 49 8B D0", [=](ptr_manage ptr) 64 | { 65 | m_get_chat_data = ptr.as(); 66 | }); 67 | main_batch.add("presence_bounty", "48 89 5C 24 ? 57 48 83 EC 20 48 8B DA 4C 8D 41 08 48 8B F9 48 8D 15 ? ? ? ? 41 B9 ? ? ? ? 48 8B CB E8 ? ? ? ? 84 C0 74 7D", [=](ptr_manage ptr) 68 | { 69 | m_presence_bounty = ptr.as(); 70 | }); 71 | main_batch.run(); 72 | MH_CreateHook(m_get_chat_data, hk_get_chat_data, (LPVOID*)&og_get_chat_data); 73 | MH_CreateHook(m_event_network_text_message_received, hk_event_network_text_message_received, (LPVOID*)&og_event_network_text_message_received); 74 | MH_CreateHook(m_presence_bounty, hk_presence_bounty, (LPVOID*)&og_presence_bounty); 75 | MH_EnableHook(MH_ALL_HOOKS); 76 | while (g_running) 77 | { 78 | 79 | } 80 | return 0; 81 | } 82 | 83 | BOOL APIENTRY DllMain( HMODULE hModule, 84 | DWORD ul_reason_for_call, 85 | LPVOID lpReserved 86 | ) 87 | { 88 | switch (ul_reason_for_call) 89 | { 90 | case DLL_PROCESS_ATTACH: 91 | DisableThreadLibraryCalls(hModule); 92 | CreateThread(NULL, NULL, static_cast(Mainthread), hModule, NULL, NULL); 93 | case DLL_THREAD_ATTACH: 94 | case DLL_THREAD_DETACH: 95 | case DLL_PROCESS_DETACH: 96 | break; 97 | } 98 | return TRUE; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Block-SpamMessage/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 4 | // Windows 头文件 5 | #include 6 | -------------------------------------------------------------------------------- /Block-SpamMessage/minhook/minhook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__) 32 | #error MinHook supports only x86 and x64 systems. 33 | #endif 34 | 35 | #include 36 | 37 | // MinHook Error Codes. 38 | typedef enum MH_STATUS 39 | { 40 | // Unknown error. Should not be returned. 41 | MH_UNKNOWN = -1, 42 | 43 | // Successful. 44 | MH_OK = 0, 45 | 46 | // MinHook is already initialized. 47 | MH_ERROR_ALREADY_INITIALIZED, 48 | 49 | // MinHook is not initialized yet, or already uninitialized. 50 | MH_ERROR_NOT_INITIALIZED, 51 | 52 | // The hook for the specified target function is already created. 53 | MH_ERROR_ALREADY_CREATED, 54 | 55 | // The hook for the specified target function is not created yet. 56 | MH_ERROR_NOT_CREATED, 57 | 58 | // The hook for the specified target function is already enabled. 59 | MH_ERROR_ENABLED, 60 | 61 | // The hook for the specified target function is not enabled yet, or already 62 | // disabled. 63 | MH_ERROR_DISABLED, 64 | 65 | // The specified pointer is invalid. It points the address of non-allocated 66 | // and/or non-executable region. 67 | MH_ERROR_NOT_EXECUTABLE, 68 | 69 | // The specified target function cannot be hooked. 70 | MH_ERROR_UNSUPPORTED_FUNCTION, 71 | 72 | // Failed to allocate memory. 73 | MH_ERROR_MEMORY_ALLOC, 74 | 75 | // Failed to change the memory protection. 76 | MH_ERROR_MEMORY_PROTECT, 77 | 78 | // The specified module is not loaded. 79 | MH_ERROR_MODULE_NOT_FOUND, 80 | 81 | // The specified function is not found. 82 | MH_ERROR_FUNCTION_NOT_FOUND 83 | } 84 | MH_STATUS; 85 | 86 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, 87 | // MH_QueueEnableHook or MH_QueueDisableHook. 88 | #define MH_ALL_HOOKS NULL 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | // Initialize the MinHook library. You must call this function EXACTLY ONCE 95 | // at the beginning of your program. 96 | MH_STATUS WINAPI MH_Initialize(VOID); 97 | 98 | // Uninitialize the MinHook library. You must call this function EXACTLY 99 | // ONCE at the end of your program. 100 | MH_STATUS WINAPI MH_Uninitialize(VOID); 101 | 102 | // Creates a Hook for the specified target function, in disabled state. 103 | // Parameters: 104 | // pTarget [in] A pointer to the target function, which will be 105 | // overridden by the detour function. 106 | // pDetour [in] A pointer to the detour function, which will override 107 | // the target function. 108 | // ppOriginal [out] A pointer to the trampoline function, which will be 109 | // used to call the original target function. 110 | // This parameter can be NULL. 111 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); 112 | 113 | // Creates a Hook for the specified API function, in disabled state. 114 | // Parameters: 115 | // pszModule [in] A pointer to the loaded module name which contains the 116 | // target function. 117 | // pszTarget [in] A pointer to the target function name, which will be 118 | // overridden by the detour function. 119 | // pDetour [in] A pointer to the detour function, which will override 120 | // the target function. 121 | // ppOriginal [out] A pointer to the trampoline function, which will be 122 | // used to call the original target function. 123 | // This parameter can be NULL. 124 | MH_STATUS WINAPI MH_CreateHookApi( 125 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); 126 | 127 | // Creates a Hook for the specified API function, in disabled state. 128 | // Parameters: 129 | // pszModule [in] A pointer to the loaded module name which contains the 130 | // target function. 131 | // pszTarget [in] A pointer to the target function name, which will be 132 | // overridden by the detour function. 133 | // pDetour [in] A pointer to the detour function, which will override 134 | // the target function. 135 | // ppOriginal [out] A pointer to the trampoline function, which will be 136 | // used to call the original target function. 137 | // This parameter can be NULL. 138 | // ppTarget [out] A pointer to the target function, which will be used 139 | // with other functions. 140 | // This parameter can be NULL. 141 | MH_STATUS WINAPI MH_CreateHookApiEx( 142 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); 143 | 144 | // Removes an already created hook. 145 | // Parameters: 146 | // pTarget [in] A pointer to the target function. 147 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 148 | 149 | // Enables an already created hook. 150 | // Parameters: 151 | // pTarget [in] A pointer to the target function. 152 | // If this parameter is MH_ALL_HOOKS, all created hooks are 153 | // enabled in one go. 154 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 155 | 156 | // Disables an already created hook. 157 | // Parameters: 158 | // pTarget [in] A pointer to the target function. 159 | // If this parameter is MH_ALL_HOOKS, all created hooks are 160 | // disabled in one go. 161 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 162 | 163 | // Queues to enable an already created hook. 164 | // Parameters: 165 | // pTarget [in] A pointer to the target function. 166 | // If this parameter is MH_ALL_HOOKS, all created hooks are 167 | // queued to be enabled. 168 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 169 | 170 | // Queues to disable an already created hook. 171 | // Parameters: 172 | // pTarget [in] A pointer to the target function. 173 | // If this parameter is MH_ALL_HOOKS, all created hooks are 174 | // queued to be disabled. 175 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 176 | 177 | // Applies all queued changes in one go. 178 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 179 | 180 | // Translates the MH_STATUS to its name as a string. 181 | const char * WINAPI MH_StatusToString(MH_STATUS status); 182 | 183 | #ifdef __cplusplus 184 | } 185 | #endif 186 | 187 | -------------------------------------------------------------------------------- /Block-SpamMessage/minhook/minhook.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HolyWurl/Block-GTASpamMessage/fb5c8ea9ee6d8264b911836ab0d0929cd0792f54/Block-SpamMessage/minhook/minhook.lib -------------------------------------------------------------------------------- /Block-SpamMessage/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: 与预编译标头对应的源文件 2 | 3 | #include "pch.h" 4 | 5 | // 当使用预编译的头时,需要使用此源文件,编译才能成功。 6 | -------------------------------------------------------------------------------- /Block-SpamMessage/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | #pragma execution_character_set("utf-8") 4 | 5 | #include "framework.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #endif //PCH_H 15 | -------------------------------------------------------------------------------- /Block-SpamMessage/sigscan.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "sigscan.h" 3 | 4 | ptr_manage::ptr_manage(void* hand) { 5 | m_ptr = hand; 6 | } 7 | ptr_manage::ptr_manage(std::uintptr_t hand) { 8 | m_ptr = reinterpret_cast(hand); 9 | } 10 | 11 | ptr_manage ptr_manage::add(int offset) { 12 | return ptr_manage(as() + offset); 13 | } 14 | 15 | sModule::sModule(HMODULE hMod) : m_begin(hMod), m_end(nullptr), m_size(0) { 16 | auto dosHeader = ptr_manage(m_begin).as(); 17 | auto ntHeader = ptr_manage(m_begin).add(dosHeader->e_lfanew).as(); 18 | m_size = ntHeader->OptionalHeader.SizeOfImage; 19 | m_end = ptr_manage(m_begin.add(m_size)); 20 | } 21 | 22 | sModule::sModule(std::string name) : sModule(GetModuleHandleA(name.c_str())) { } 23 | 24 | ptr_manage sModule::get_begin() { 25 | return m_begin; 26 | } 27 | 28 | ptr_manage sModule::get_end() { 29 | return m_end; 30 | } 31 | 32 | ptr_manage sModule::get_export(std::string proc_name) { 33 | return ptr_manage(GetProcAddress(m_begin.as(), proc_name.c_str())); 34 | } 35 | 36 | 37 | find_pattern::find_pattern(const char* pattern) { 38 | auto toUpper = [](char c) -> char { 39 | return c >= 'a' && c <= 'z' ? static_cast(c + ('A' - 'a')) : static_cast(c); 40 | }; 41 | auto isHex = [&](char c) -> bool { 42 | switch (toUpper(c)) { 43 | case '0': 44 | case '1': 45 | case '2': 46 | case '3': 47 | case '4': 48 | case '5': 49 | case '6': 50 | case '7': 51 | case '8': 52 | case '9': 53 | case 'A': 54 | case 'B': 55 | case 'C': 56 | case 'D': 57 | case 'E': 58 | case 'F': 59 | return true; 60 | default: 61 | return false; 62 | } 63 | }; 64 | do { 65 | if (*pattern == ' ') 66 | continue; 67 | if (*pattern == '?') { 68 | Element e = Element({}, true); 69 | m_elements.push_back(e); 70 | continue; 71 | } 72 | if (*(pattern + 1) && isHex(*pattern) && isHex(*(pattern + 1))) { 73 | char str[3] = { *pattern, *(pattern + 1), '\0' }; 74 | auto data = std::strtol(str, nullptr, 16); 75 | 76 | Element e = Element(static_cast(data), false); 77 | m_elements.push_back(e); 78 | } 79 | } while (*(pattern++)); 80 | } 81 | 82 | ptr_manage find_pattern::scan(sModule region) { 83 | auto compareMemory = [](std::uint8_t* data, Element* elem, std::size_t num) -> bool { 84 | for (std::size_t i = 0; i < num; ++i) { 85 | if (!elem[i].m_wildcard) 86 | if (data[i] != elem[i].m_data) 87 | return false; 88 | } 89 | return true; 90 | }; 91 | for (std::uintptr_t i = region.get_begin().as(), end = region.get_end().as(); i != end; ++i) { 92 | if (compareMemory(reinterpret_cast(i), m_elements.data(), m_elements.size())) 93 | return ptr_manage(i); 94 | } 95 | return nullptr; 96 | } 97 | 98 | pattern_hisnt::pattern_hisnt(std::string name, find_pattern pattern, std::function callback) : m_name(std::move(name)), m_pattern(std::move(pattern)), m_callback(std::move(callback)) { } 99 | 100 | void pattern_batch::add(std::string name, find_pattern pattern, std::function callback) { 101 | pattern_list.emplace_back(name, pattern, callback); 102 | } 103 | 104 | void pattern_batch::run() { 105 | const sModule module = { GetModuleHandle(nullptr) }; 106 | for (auto& hisnt : pattern_list) { 107 | if (auto result = hisnt.m_pattern.scan(module)) { 108 | if (!hisnt.m_callback) 109 | continue; 110 | if (!result.as()) 111 | continue; 112 | std::invoke(std::move(hisnt.m_callback), result); 113 | if (!std::strcmp(hisnt.m_name.c_str(), "")) 114 | continue; 115 | } 116 | } 117 | pattern_list.clear(); 118 | } -------------------------------------------------------------------------------- /Block-SpamMessage/sigscan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ptr_manage { 4 | public: 5 | ptr_manage(void* hand = 0); 6 | ptr_manage(std::uintptr_t hand = 0); 7 | 8 | template 9 | inline std::enable_if_t::value, T> as() { 10 | return static_cast(m_ptr); 11 | } 12 | 13 | template 14 | inline std::enable_if_t::value, T> as() { 15 | return *static_cast>>(m_ptr); 16 | } 17 | 18 | template 19 | inline std::enable_if_t::value, T> as() { 20 | return reinterpret_cast(m_ptr); 21 | } 22 | 23 | ptr_manage add(int offset); 24 | 25 | inline operator bool() { return m_ptr != nullptr; } 26 | private: 27 | void* m_ptr; 28 | }; 29 | 30 | class sModule { 31 | public: 32 | sModule(HMODULE hMod); 33 | sModule(std::string name); 34 | 35 | ptr_manage get_begin(); 36 | ptr_manage get_end(); 37 | ptr_manage get_export(std::string proc_name); 38 | 39 | private: 40 | ptr_manage m_begin; 41 | ptr_manage m_end; 42 | size_t m_size{}; 43 | std::string m_name{}; 44 | }; 45 | 46 | class find_pattern { 47 | public: 48 | struct Element { 49 | std::uint8_t m_data{}; 50 | bool m_wildcard{}; 51 | Element(uint8_t data, bool wildcard) : m_data(data), m_wildcard(wildcard) { } 52 | }; 53 | find_pattern(const char* pattern); 54 | ptr_manage scan(sModule region = sModule(nullptr)); 55 | 56 | private: 57 | const char* m_pat; 58 | std::vector m_elements; 59 | }; 60 | 61 | struct pattern_hisnt { 62 | std::string m_name; 63 | find_pattern m_pattern; 64 | std::function m_callback; 65 | 66 | pattern_hisnt(std::string name, find_pattern pattern, std::function callback); 67 | }; 68 | 69 | class pattern_batch { 70 | public: 71 | void add(std::string name, find_pattern pattern, std::function callback); 72 | void run(); 73 | private: 74 | std::vector pattern_list; 75 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Block-GTASpamMessage 2 | Block-Spam small plug-ins in GTAOnline. 3 | ## Function 4 | 1. It can block useless text messages and useless text chat. 5 | 2. It will not change others in your games, it's just a small plug-ins. 6 | 3. It can block bounty presence event 7 | ## Picture 8 | ![image](example.png) 9 | Of course, there's chat. I didn't screenshot it. 10 | ## Why 11 | For bad game environment. 12 | ## How to use it 13 | Compile it 14 | -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HolyWurl/Block-GTASpamMessage/fb5c8ea9ee6d8264b911836ab0d0929cd0792f54/example.png --------------------------------------------------------------------------------