├── .editorconfig ├── .gitattributes ├── .gitignore ├── Assets └── Fonts │ └── JNMYT.ttf ├── LICENSE.txt ├── Memory ├── Mem.cpp ├── Mem.h ├── MinHook.h ├── SlimMem.cpp └── SlimMem.h ├── Mod.sln ├── Mod ├── Hook │ ├── Hook.cpp │ ├── Hook.h │ └── HookFunction.h ├── Loader.cpp ├── Loader.h ├── Mod.rc ├── Mod.vcxproj ├── Mod.vcxproj.filters ├── Modules │ ├── Module.cpp │ ├── Module.h │ ├── ModuleManager.cpp │ ├── ModuleManager.h │ └── Modules │ │ ├── AirJump.cpp │ │ ├── AirJump.h │ │ ├── ArmsLength.cpp │ │ ├── ArmsLength.h │ │ ├── BioRadar.cpp │ │ ├── BioRadar.h │ │ ├── ChangeGameMode.cpp │ │ ├── ChangeGameMode.h │ │ ├── Debug.cpp │ │ ├── Debug.h │ │ ├── FastViewPerspective.cpp │ │ ├── FastViewPerspective.h │ │ ├── FreeCamera.cpp │ │ ├── FreeCamera.h │ │ ├── GameTimeLock.cpp │ │ ├── GameTimeLock.h │ │ ├── HitBox.cpp │ │ ├── HitBox.h │ │ ├── HivePeekABooXRay.cpp │ │ ├── HivePeekABooXRay.h │ │ ├── HiveTreasurePos.cpp │ │ ├── HiveTreasurePos.h │ │ ├── HundredTimesMoreDrops.cpp │ │ ├── HundredTimesMoreDrops.h │ │ ├── InstantDestroy.cpp │ │ ├── InstantDestroy.h │ │ ├── LockControlInput.cpp │ │ ├── LockControlInput.h │ │ ├── NoAttackFriend.cpp │ │ ├── NoAttackFriend.h │ │ ├── NoKnockback.cpp │ │ ├── NoKnockback.h │ │ ├── RenderHealth.cpp │ │ ├── RenderHealth.h │ │ ├── RenderUI.cpp │ │ ├── RenderUI.h │ │ ├── ShowCoordinates.cpp │ │ ├── ShowCoordinates.h │ │ ├── TPPoint.cpp │ │ ├── TPPoint.h │ │ ├── Traverse.cpp │ │ └── Traverse.h ├── Render │ ├── Render.cpp │ └── Render.h ├── Utils │ ├── Game.cpp │ ├── Game.h │ ├── HMath.h │ ├── Json.hpp │ ├── Logger.cpp │ ├── Logger.h │ ├── Utils.cpp │ ├── Utils.h │ ├── config.cpp │ ├── config.h │ ├── http.hpp │ └── xorstr.h ├── dllmain.cpp ├── framework.h ├── imgui │ ├── HookImgui.h │ ├── imgui │ │ ├── imconfig.h │ │ ├── imgui.cpp │ │ ├── imgui.h │ │ ├── imgui_demo.cpp │ │ ├── imgui_draw.cpp │ │ ├── imgui_impl_dx11.cpp │ │ ├── imgui_impl_dx11.h │ │ ├── imgui_impl_dx12.cpp │ │ ├── imgui_impl_dx12.h │ │ ├── imgui_impl_win32.cpp │ │ ├── imgui_impl_win32.h │ │ ├── imgui_internal.h │ │ ├── imgui_tables.cpp │ │ ├── imgui_widgets.cpp │ │ ├── imstb_rectpack.h │ │ ├── imstb_textedit.h │ │ └── imstb_truetype.h │ ├── imgui_uwp_wndProc.cpp │ ├── imgui_uwp_wndProc.h │ ├── kiero │ │ ├── kiero.cpp │ │ └── kiero.h │ └── toggle │ │ ├── imgui_offset_rect.h │ │ ├── imgui_toggle.cpp │ │ ├── imgui_toggle.h │ │ ├── imgui_toggle_math.h │ │ ├── imgui_toggle_palette.cpp │ │ ├── imgui_toggle_palette.h │ │ ├── imgui_toggle_presets.cpp │ │ ├── imgui_toggle_presets.h │ │ ├── imgui_toggle_renderer.cpp │ │ └── imgui_toggle_renderer.h ├── resource.h └── version.h ├── README.md ├── SDK ├── AABB.cpp ├── AABB.h ├── Actor.cpp ├── Actor.h ├── ActorCollision.cpp ├── ActorCollision.h ├── ActorMovementProxy.cpp ├── ActorMovementProxy.h ├── AttributeInstance.cpp ├── AttributeInstance.h ├── Block.cpp ├── Block.h ├── BlockLegacy.cpp ├── BlockLegacy.h ├── BlockSource.cpp ├── BlockSource.h ├── ClientInstance.cpp ├── ClientInstance.h ├── Dimension.cpp ├── Dimension.h ├── FishingHook.cpp ├── FishingHook.h ├── GameMode.cpp ├── GameMode.h ├── GuiData.h ├── Item.cpp ├── Item.h ├── ItemInstance.cpp ├── ItemInstance.h ├── ItemStack.cpp ├── ItemStack.h ├── ItemStackBase.cpp ├── ItemStackBase.h ├── Level.cpp ├── Level.h ├── LocalPlayer.cpp ├── LocalPlayer.h ├── LoopbackPacketSender.cpp ├── LoopbackPacketSender.h ├── MinecraftUIRenderContext.cpp ├── MinecraftUIRenderContext.h ├── Mob.cpp ├── Mob.h ├── Packet.cpp ├── Packet.h ├── Player.cpp ├── Player.h ├── RemotePlayer.cpp ├── RemotePlayer.h ├── ServerPlayer.cpp ├── ServerPlayer.h ├── mcstring.h └── sdk.h └── minhook ├── libMinHook.x64-v143-md.lib └── libMinHook.x64-v143-mdd.lib /.editorconfig: -------------------------------------------------------------------------------- 1 | # Visual Studio 生成了具有 C++ 设置的 .editorconfig 文件。 2 | root = true 3 | 4 | [*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}] 5 | # 必须要手动保存的时候才有效果 6 | charset = utf-8-bom -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /Assets/Fonts/JNMYT.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cngege/Mod/bb1c3ae96d33438e9d6a544a3b9855e86cb21284/Assets/Fonts/JNMYT.ttf -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 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 | -------------------------------------------------------------------------------- /Memory/Mem.cpp: -------------------------------------------------------------------------------- 1 | #include "Mem.h" 2 | 3 | uintptr_t Mem::findSig(const char* sig){ 4 | const char* pattern = sig; 5 | uintptr_t firstMatch = 0; 6 | static const uintptr_t rangeStart = (uintptr_t)GetModuleHandleA("Minecraft.Windows.exe"); 7 | static MODULEINFO miModInfo; 8 | static bool init = false; 9 | if (!init) { 10 | init = true; 11 | GetModuleInformation(GetCurrentProcess(), (HMODULE)rangeStart, &miModInfo, sizeof(MODULEINFO)); 12 | } 13 | static const uintptr_t rangeEnd = rangeStart + miModInfo.SizeOfImage; 14 | 15 | BYTE patByte = GET_BYTE(pattern); 16 | const char* oldPat = pattern; 17 | 18 | for (uintptr_t pCur = rangeStart; pCur < rangeEnd; pCur++){ 19 | if (!*pattern) 20 | return firstMatch; 21 | 22 | while (*(PBYTE)pattern == ' ') 23 | pattern++; 24 | 25 | if (!*pattern) 26 | return firstMatch; 27 | 28 | if (oldPat != pattern){ 29 | oldPat = pattern; 30 | if (*(PBYTE)pattern != '\?') 31 | patByte = GET_BYTE(pattern); 32 | }; 33 | 34 | if (*(PBYTE)pattern == '\?' || *(BYTE*)pCur == patByte){ 35 | if (!firstMatch) 36 | firstMatch = pCur; 37 | 38 | if (!pattern[2]) 39 | return firstMatch; 40 | 41 | pattern += 2; 42 | } 43 | else { 44 | pattern = sig; 45 | firstMatch = 0; 46 | }; 47 | }; 48 | return NULL; 49 | }; 50 | 51 | uintptr_t Mem::findMultiLvlPtr(uintptr_t baseAddr, std::vector offsets){ 52 | uintptr_t addr = baseAddr; 53 | 54 | for (int I = 0; I < offsets.size(); I++){ 55 | addr = *(uintptr_t*)(addr); 56 | if ((uintptr_t*)(addr) == nullptr) 57 | return addr; 58 | addr += offsets[I]; 59 | }; 60 | 61 | return addr; 62 | }; 63 | -------------------------------------------------------------------------------- /Memory/Mem.h: -------------------------------------------------------------------------------- 1 | #ifndef MEM_MEM 2 | #define MEM_MEM 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define INRANGE(x,a,b) (x >= a && x <= b) 9 | #define GET_BYTE( x ) (GET_BITS(x[0]) << 4 | GET_BITS(x[1])) 10 | #define GET_BITS( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0)) 11 | 12 | class Mem { 13 | public: 14 | static auto findSig(const char*) -> uintptr_t; 15 | static auto findMultiLvlPtr(uintptr_t, std::vector) -> uintptr_t; 16 | }; 17 | 18 | #endif /* MEM_MEM */ -------------------------------------------------------------------------------- /Memory/SlimMem.cpp: -------------------------------------------------------------------------------- 1 | #include "SlimMem.h" 2 | #include 3 | #include 4 | #include 5 | 6 | inline bool IsProcessHandleValid(HANDLE h) { return h > (void*)0 && h != INVALID_HANDLE_VALUE; }; 7 | inline bool IsHandleValid(HANDLE h) { return h != INVALID_HANDLE_VALUE; } 8 | inline BOOL ProperlyCloseHandle(HANDLE h) { 9 | auto const b = CloseHandle(h); 10 | assert(b); 11 | return b; 12 | } 13 | 14 | static std::wstring ToLower(std::wstring string) { 15 | transform(string.begin(), string.end(), string.begin(), tolower); 16 | return string; 17 | } 18 | 19 | namespace SlimUtils { 20 | 21 | bool SlimMem::HasProcessHandle() const { return IsProcessHandleValid(m_hProc); } 22 | 23 | #pragma region Constructors/Destructors 24 | SlimMem::SlimMem(const SlimMem & copy) 25 | { 26 | m_dwPID = 0; 27 | DuplicateHandle(GetCurrentProcess(), copy.m_hProc, GetCurrentProcess(), &m_hProc, NULL, FALSE, DUPLICATE_SAME_ACCESS); 28 | } 29 | 30 | SlimMem::~SlimMem() 31 | { 32 | Close(); 33 | } 34 | #pragma endregion 35 | 36 | #pragma region Open/Close 37 | void SlimMem::Close() 38 | { 39 | m_mModules.clear(); 40 | 41 | //Close the handle to the process in case it's still open 42 | if (IsProcessHandleValid(m_hProc)) { 43 | ProperlyCloseHandle(m_hProc); 44 | } 45 | } 46 | 47 | bool SlimMem::Open(const wchar_t * lpwstrProcessName, ProcessAccess flags) 48 | { 49 | return Open(lpwstrProcessName, (DWORD)flags); 50 | } 51 | 52 | bool SlimMem::Open(const wchar_t * lpwstrProcessName, DWORD flags) 53 | { 54 | DWORD pid; 55 | if (GetPID(lpwstrProcessName, &pid)) 56 | return Open(pid, flags); 57 | return false; 58 | } 59 | 60 | bool SlimMem::Open(DWORD dwPID, ProcessAccess flags) 61 | { 62 | return Open(dwPID, (DWORD)flags); 63 | } 64 | 65 | bool SlimMem::Open(DWORD dwPID, DWORD dwFlags) 66 | { 67 | if (HasProcessHandle()) { 68 | 69 | return false; 70 | } 71 | 72 | 73 | m_hProc = OpenProcess(dwFlags | PROCESS_DUP_HANDLE, false, dwPID); 74 | m_dwPID = dwPID; 75 | if (HasProcessHandle()) 76 | ParseModules(); 77 | 78 | 79 | return HasProcessHandle(); 80 | } 81 | #pragma endregion 82 | 83 | #pragma region Utility 84 | /* 85 | Attempts to find a process with a given name and sets the given PID 86 | Returns whether a matching process was found or not 87 | */ 88 | bool SlimMem::GetPID(const wchar_t * lpwstrProcessName, DWORD* pid) 89 | { 90 | PROCESSENTRY32W proc; 91 | proc.dwSize = sizeof(PROCESSENTRY32W); 92 | HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 93 | *pid = 0; 94 | 95 | if (!IsHandleValid(hSnap)) 96 | return false; 97 | 98 | if (Process32FirstW(hSnap, &proc)) { 99 | do { 100 | if (wcscmp(lpwstrProcessName, proc.szExeFile) == 0) 101 | { 102 | ProperlyCloseHandle(hSnap); 103 | *pid = proc.th32ProcessID; 104 | return true; 105 | } 106 | } while (Process32NextW(hSnap, &proc)); 107 | } 108 | 109 | ProperlyCloseHandle(hSnap); 110 | return false; 111 | } 112 | 113 | /* 114 | Caches basic information of modules loaded by the opened-process 115 | 116 | */ 117 | bool SlimMem::ParseModules() 118 | { 119 | if (!HasProcessHandle()) 120 | return false; 121 | 122 | m_mModules.clear(); 123 | 124 | MODULEENTRY32W mod; 125 | mod.dwSize = sizeof(MODULEENTRY32W); 126 | 127 | HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, m_dwPID); 128 | if (!IsHandleValid(hSnap)) 129 | return false; 130 | 131 | if (Module32FirstW(hSnap, &mod)) { 132 | do { 133 | try { 134 | if (m_mModules.find(std::wstring(mod.szModule)) == m_mModules.end()) 135 | m_mModules[ToLower(mod.szModule)] = std::make_unique((std::uintptr_t) mod.modBaseAddr, mod.modBaseSize); 136 | } 137 | catch (...) { 138 | 139 | } 140 | } while (Module32NextW(hSnap, &mod)); 141 | } 142 | 143 | ProperlyCloseHandle(hSnap); 144 | return true; 145 | } 146 | 147 | SigScanResult SlimMem::PerformSigScan(const BYTE * bufPattern, const char * lpcstrMask, const SlimModule * Module, DWORD startFromOffset) 148 | { 149 | auto module = Module; 150 | if (module == nullptr) 151 | return SigScanResult(false); 152 | std::string mask(lpcstrMask); 153 | 154 | if (mask.empty()) 155 | return SigScanResult(false); 156 | 157 | if (module->dwSize <= startFromOffset) 158 | return SigScanResult(false); 159 | 160 | if (startFromOffset > module->dwSize - mask.size()) 161 | return SigScanResult(false); 162 | 163 | if (mask[0] != 'x') { 164 | 165 | return SigScanResult(false); 166 | } 167 | 168 | 169 | 170 | BYTE *dump = new BYTE[module->dwSize]; 171 | 172 | SIZE_T bytesRead; 173 | 174 | if (!ReadProcessMemory(m_hProc, (LPCVOID)module->ptrBase, dump, module->dwSize, &bytesRead) || bytesRead != module->dwSize) 175 | return SigScanResult(false); 176 | 177 | bool found = false; 178 | size_t maskSize = mask.size(); 179 | const char * goodMask = mask.c_str(); 180 | DWORD count = (DWORD)(module->dwSize - maskSize); 181 | for (DWORD i = startFromOffset; i < count; i++) { 182 | if (bufPattern[0] == dump[i]) { 183 | found = true; 184 | for (DWORD idx = 1; idx < maskSize; idx++) { 185 | 186 | if (goodMask[idx] == 0x78 && bufPattern[idx] != dump[i + idx]) { 187 | found = false; 188 | break; 189 | } 190 | } 191 | if (found) { 192 | SigScanResult result(true, i, dump + i, (DWORD)maskSize); 193 | delete[] dump; 194 | return result; 195 | } 196 | } 197 | } 198 | delete[] dump; 199 | 200 | return SigScanResult(false); 201 | } 202 | 203 | const SlimModule* SlimMem::GetModule(const wchar_t * lpwstrModuleName) const 204 | { 205 | std::wstring name = ToLower(std::wstring(lpwstrModuleName)); 206 | auto val = m_mModules.find(name); 207 | if (val == m_mModules.end()) 208 | return nullptr; 209 | 210 | return (*val).second.get(); 211 | } 212 | 213 | #pragma endregion 214 | } -------------------------------------------------------------------------------- /Mod.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32414.318 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mod", "Mod\Mod.vcxproj", "{C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}" 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 | Repair|x64 = Repair|x64 15 | Repair|x86 = Repair|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Debug|x64.ActiveCfg = Debug|x64 19 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Debug|x64.Build.0 = Debug|x64 20 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Debug|x86.ActiveCfg = Debug|Win32 21 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Debug|x86.Build.0 = Debug|Win32 22 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Release|x64.ActiveCfg = Release|x64 23 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Release|x64.Build.0 = Release|x64 24 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Release|x86.ActiveCfg = Release|Win32 25 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Release|x86.Build.0 = Release|Win32 26 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Repair|x64.ActiveCfg = Repair|x64 27 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Repair|x64.Build.0 = Repair|x64 28 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Repair|x86.ActiveCfg = Repair|Win32 29 | {C32B25E8-7DF9-4FCA-80F8-2CDEAB533EA9}.Repair|x86.Build.0 = Repair|Win32 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {0AD6E94D-8C59-473D-9D41-5D45E31A7E13} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Mod/Hook/Hook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma execution_character_set("utf-8") 3 | #include 4 | #include "../../Memory/MinHook.h" 5 | #include "../Utils/HMath.h" 6 | #include "ClientInstance.h" 7 | 8 | template 9 | inline MH_STATUS MH_CreateHookEx(LPVOID pTarget, LPVOID pDetour, T** ppOriginal) 10 | { 11 | return MH_CreateHook(pTarget, pDetour, reinterpret_cast(ppOriginal)); 12 | } 13 | class Packet; 14 | class Hook 15 | { 16 | public: 17 | static auto init() ->void; 18 | static auto exit() ->void; 19 | static auto LockControlInputCallBack(void* thi, void* a2, void* a3, void* a4, void* a5, void* a6) -> void*; 20 | static auto SetVelocity(class Actor* ,vec3_t*)->void*; 21 | //static auto Actor_isInWater(class Actor*) -> bool; 22 | static auto Actor_isInvisible(class Actor*) -> bool; 23 | static auto Actor_getShadowRadius(class Actor*)->float; //执行对象是所有生物 但不包括玩家 24 | static auto ClientInstance_Tick(ClientInstance*, void*)-> uintptr_t; 25 | static auto Is_ShowCoordinates_Tick(void*, void*, void*)->bool; 26 | //static auto NoFallDamage_Tick(class Player*,float*)->void*; 27 | static auto Level_Tick(class Level*) -> void*; 28 | //Player 虚表Hook 29 | //static auto LocalPlayer_getCameraOffset(class LocalPlayer*)->vec2_t*; 30 | static auto Player_tickWorld(class Player*, class Tick*)->void; 31 | static auto Player_getShadowRadius(class Player*)->float; 32 | //static auto Player_startSwimming(class Player*) -> void; 33 | 34 | static auto AllActor_Tick(class Actor*, float*, float)->float*; 35 | static auto AllPlayer_Tick(void* a1, class Player*) -> char; 36 | //static auto Actor_moveBBs(class Actor*, vec3_t*)->void*; 37 | static auto KeyUpdate(__int64, int)->void*; 38 | static auto MouseUpdate(__int64, char, char, __int16, __int16, __int16, __int16, char)->void; 39 | //static auto RenderDetour(void*, class MinecraftUIRenderContext*)->void; 40 | //static auto Draw_Text(class MinecraftUIRenderContext*,class BitmapFont*, struct RectangleArea const&, class TextHolder*, struct UIColor const& , float , float , struct TextMeasureData*, class CaretMeasureData*)->void; 41 | static auto sendMessage(void*, std::mcstring*)->__int64; 42 | static auto getLocalPlayerViewPerspective(void*)->int; 43 | static auto level_startLeaveGame(class Level*) -> void; 44 | public: 45 | //虚表Hook 46 | static auto GameMode_attack(class GameMode*, class Actor*)->bool; 47 | static auto GameMode_tick(class GameMode*)->void*; 48 | static auto GameMode_startDestroyBlock(class GameMode* _this, vec3_ti* a2, uint8_t* face, void* a3, void* a4)->bool; 49 | static auto GameMode_useItem(class GameMode*,class ItemStack*)->bool; 50 | static auto GameMode_useItemOn(class GameMode*, class ItemStack*, class ItemInstance*, vec3_ti*, uint8_t*, vec3_t*, class Block*)->bool; 51 | 52 | static auto LocalPlayer_TickWorld(class LocalPlayer* _this, void* tick) -> void*; 53 | static auto ServerPlayer_TickWorld(class ServerPlayer* _this, void* tick)->void*; 54 | static auto RemotePlayer_TickWorld(class RemotePlayer* _this) -> void*; //由于该函数只是个空架子,所以只能接受一个参数 55 | 56 | static auto LoopbackPacketSender_SendServer(class LoopbackPacketSender*, Packet*) -> void*; 57 | 58 | static auto ClientInstance_onDimensionChanged(ClientInstance*) -> void*; 59 | }; -------------------------------------------------------------------------------- /Mod/Hook/HookFunction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | // TODO 设计一个类 暂不可用 5 | // 包含被Hook的函数 6 | // 原函数 7 | 8 | template 9 | class HookFunction { 10 | public: 11 | using FnType = TRet(__fastcall*)(TArgs...); 12 | using Fn = std::function; 13 | private: 14 | uintptr_t* Ori_Fun = nullptr; 15 | Fn Hooked_Fun; 16 | 17 | public: 18 | 19 | 20 | public: 21 | TRet call(TArgs... args) { 22 | return reinterpret_cast(Ori_Fun)(args); 23 | } 24 | 25 | void set(Fn lambdafun) { 26 | Hooked_Fun = lambdafun; 27 | } 28 | 29 | void* getOriFun() { 30 | return (void*)&Ori_Fun; 31 | } 32 | 33 | void* getHookedFun() { 34 | return &Hooked_Fun; 35 | } 36 | 37 | }; 38 | 39 | 40 | 41 | 42 | // 定义 43 | // HookFunction HF_setSpeed; 44 | 45 | // 创建被自定义Hook函数; 46 | // 47 | 48 | // 创建Hook 49 | //1 MH_CreatHookEx(xx, &Actor::HF_setSpeed.Hooked_Fun, &Actor::HF_serSpeed.OriFun); 50 | //2 MH_CreatHookEx(xx, &Actor::HF_setSpeed, &Actor::HF_serSpeed.OriFun); -------------------------------------------------------------------------------- /Mod/Loader.cpp: -------------------------------------------------------------------------------- 1 | #include "Loader.h" 2 | #include "version.h" 3 | #include "http.hpp" 4 | #include 5 | #include "Utils/Logger.h" 6 | #include "Utils/Game.h" 7 | #include "Hook/Hook.h" 8 | #include "Utils/Utils.h" 9 | //Modules 10 | #include "Modules/ModuleManager.h" 11 | //imgui hook 12 | #include "imgui/HookImgui.h" 13 | #include 14 | //config 15 | #include "Utils/config.h" 16 | 17 | MH_STATUS hookret; 18 | void* Loader::dllHMODULE = nullptr; 19 | bool Loader::Eject_Signal = false; 20 | bool Loader::RemoteFreeLib = false; 21 | bool Loader::EnableEjectKey = true; 22 | 23 | static DWORD WINAPI FreeLibraryThread(LPVOID lpParam); 24 | 25 | //在线程 26 | void Loader::init(void* hmodule) 27 | { 28 | logF("DLL VER: %s at %s , HMODULE: %llX", FILE_VERSION_FILE_VERSION_STRING, __TIMESTAMP__ , hmodule); 29 | std::string mcVersion = Utils::getMCVersion(); 30 | logF("Minecraft.Windows.exe base: %llX, Ver: %s", Utils::getBase(), mcVersion.c_str()); 31 | 32 | dllHMODULE = hmodule; 33 | hookret = MH_Initialize(); 34 | if (hookret != MH_OK) 35 | { 36 | logF("MH_Initialize Error ret is %s ,Mod Return", MH_StatusToString(hookret)); 37 | return; 38 | } 39 | 40 | //创建相关文件夹与 下载字体 41 | { 42 | std::wstring modPath = Logger::GetRoamingFolderPath() + Utils::stringToWstring("\\Mod\\"); 43 | std::wstring assetsPath = Logger::GetRoamingFolderPath() + Utils::stringToWstring("\\Mod\\Assets\\"); 44 | std::wstring configPath = Logger::GetRoamingFolderPath() + Utils::stringToWstring("\\Mod\\Config\\"); 45 | std::string font_JNMYT = Utils::WStringToString(Logger::GetRoamingFolderPath()) + std::string("\\Mod\\Assets\\JNMYT.ttf"); 46 | 47 | //检测 资源等相关文件夹是否存在并创建 48 | CreateDirectory((LPCWSTR)(modPath).c_str(), NULL); 49 | CreateDirectory((LPCWSTR)(assetsPath).c_str(), NULL); 50 | CreateDirectory((LPCWSTR)(configPath).c_str(), NULL); 51 | { 52 | //检测字体文件是否存在及下载 53 | if (_access(font_JNMYT.c_str(),0 /*F_OK*/) == -1) { 54 | //线程网络下载 55 | std::thread netdownload([font_JNMYT]() { 56 | logF("[Loader::init] 线程中: 正在下载字体文件 JNMYT.ttf"); 57 | 58 | auto client = NetClient::GetAsync("https://raw.githubusercontent.com/cngege/Mod/master/Assets/Fonts/JNMYT.ttf"); 59 | if (!client.StatusSuccess()) { 60 | logF("[Loader::init Error]Font Download fail AS StatusSuccess = false, statuscode = %i",client.StatusCode); 61 | return; 62 | } 63 | auto buff = client.GetAsyncAsBuffer(); 64 | if (!NetClient::WriteFile(font_JNMYT, buff)) { 65 | logF("[Loader::init Error]Font Download fail AS WriteFile fail"); 66 | return; 67 | } 68 | logF("[Loader::init Success]Font Download Success, restart work"); 69 | }); 70 | netdownload.detach(); 71 | } 72 | } 73 | } 74 | logF("正在初始化Game模块"); 75 | Game::init(); 76 | logF("正在初始化ImGuiHook模块"); // Hook 的先后顺序无关紧要,因为都是统一的开启Hook MH_EnableHook(MH_ALL_HOOKS) 77 | ImguiHooks::InitImgui(); // 23/9/21 最后检测结果, 注释此条则Mod不会崩溃 78 | logF("正在进行游戏进程Hook"); 79 | Hook::init(); 80 | 81 | logF("[MH_EnableHook] Hook状态: %s", MH_StatusToString(MH_EnableHook(MH_ALL_HOOKS))); 82 | CreateThread(NULL, NULL, FreeLibraryThread, hmodule, NULL, NULL); 83 | } 84 | 85 | static DWORD WINAPI FreeLibraryThread(LPVOID lpParam) { 86 | while (!Loader::Eject_Signal) 87 | { 88 | Sleep(500); 89 | if (Loader::RemoteFreeLib) { 90 | logF("[thread while] 检测远程释放库信号."); 91 | return 0; 92 | } 93 | } 94 | logF("[thread while] 检测到退出信号."); 95 | ::FreeLibraryAndExitThread(static_cast(lpParam), 0); //只能退出 CreateThread 创建的线程 96 | return 0; 97 | } 98 | 99 | void Loader::exit(void* hmodule) 100 | { 101 | if (Game::ModState) { 102 | logF("=============================="); // =x30 103 | if (hookret == MH_OK) 104 | { 105 | logF("[Loader::exit] 正在关闭所有Hook"); 106 | Hook::exit(); 107 | logF("[Loader::exit] Hook解除状态: %s", MH_StatusToString(MH_Uninitialize())); 108 | hookret = MH_STATUS::MH_UNKNOWN; 109 | } 110 | logF("[Loader::exit] 正在关闭D3D12渲染"); 111 | ImguiHooks::CloseImGui(); 112 | logF("[Loader::exit] 正在退出Game模块"); 113 | Game::exit(); 114 | logF("[Loader::exit] Removing logger"); 115 | Logger::Disable(); 116 | //关闭被注入程序的时候会调用 117 | } 118 | } 119 | 120 | -------------------------------------------------------------------------------- /Mod/Loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Loader { 4 | public: 5 | static void* dllHMODULE; 6 | static bool Eject_Signal; 7 | static bool RemoteFreeLib; 8 | static bool EnableEjectKey; 9 | public: 10 | static auto init(void*)->void; 11 | static auto exit(void*)->void; 12 | }; -------------------------------------------------------------------------------- /Mod/Mod.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cngege/Mod/bb1c3ae96d33438e9d6a544a3b9855e86cb21284/Mod/Mod.rc -------------------------------------------------------------------------------- /Mod/Modules/Module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "../Utils/Utils.h" 5 | #include "../Utils/config.h" 6 | #include "HMath.h" 7 | #include "mcstring.h" 8 | 9 | enum KeyMode { 10 | Trigger = 0, //按下 触发 onTrigger(); 11 | Switch = 1, //按下一次 isenable 的值就切换一次 同时也会触发对应的 onEnable() onDisable() 12 | Hold = 2 //按下 触发 onEnable() 松开触发 onDisable() 13 | }; 14 | 15 | struct IntUIValue 16 | { 17 | std::string name{}; 18 | int* value = nullptr; 19 | int min = 0; 20 | int max = 0; 21 | bool slider = false; 22 | float speed = 0; 23 | }; 24 | 25 | struct FloatUIValue 26 | { 27 | std::string name{}; 28 | float* value = nullptr; 29 | float min = 0; 30 | float max = 0; 31 | bool slider = false; 32 | float speed = 0; 33 | }; 34 | 35 | struct BoolUIValue 36 | { 37 | std::string name; 38 | bool* value = nullptr; 39 | }; 40 | 41 | struct ButtonUIEvent 42 | { 43 | std::string name; 44 | bool sameline; //同一行 和前一个UI之间不换行 45 | std::function et; 46 | }; 47 | 48 | struct ImColor; 49 | struct ColorUIValue 50 | { 51 | std::string name; 52 | ImColor* value = nullptr; 53 | }; 54 | 55 | 56 | class Module 57 | { 58 | protected: 59 | Module(int key,std::string name,std::string info); 60 | public: 61 | virtual ~Module(); 62 | private: 63 | bool enabled = false; 64 | int keybind = 0x00; 65 | std::vector controlkeys = std::vector(); //是否要求功能键也要按下 66 | std::string modulename; 67 | std::string moduleinfo; 68 | KeyMode km = KeyMode::Switch; 69 | 70 | std::vector intUIValue = std::vector(); 71 | std::vector floatUIValue = std::vector(); 72 | std::vector boolUIValue = std::vector(); 73 | std::vector colorUIValue = std::vector(); 74 | std::vector buttonUIEvent = std::vector(); 75 | 76 | public: 77 | void SetKeyMode(KeyMode km); 78 | KeyMode GetKeyMode(); 79 | protected: 80 | void AddIntUIValue(std::string name, int* defautvalue_ptr, int minvalue, int maxvalue, bool slider = true, float speed = 1.f); 81 | void AddFloatUIValue(std::string name, float* defautvalue_ptr, float minvalue, float maxvalue, bool slider = true, float speed = 0.05f); 82 | void AddBoolUIValue(std::string name, bool* defautvalue_ptr); 83 | void AddColorUIValue(std::string name, ImColor* defautvalue_ptr); 84 | void AddButtonUIEvent(std::string name, bool sameline, std::function et); 85 | public: 86 | std::vector GetIntUIValue(); 87 | std::vector GetFloatUIValue(); 88 | std::vector GetBoolUIValue(); 89 | std::vector GetColorUIValue(); 90 | std::vector GetButtonUIEvent(); 91 | public: 92 | virtual int getKeybind(); 93 | virtual void setKeybind(int key); 94 | virtual std::vector getcontrolkeysbind(); 95 | virtual bool checkcontrolkeys(); 96 | virtual void setcontrolkeysbind(std::vector key); 97 | virtual std::string getModuleName(); 98 | virtual std::string getModuleInfo(); 99 | virtual std::string getBindKeyName(); 100 | virtual void onTick(class GameMode*); 101 | virtual void onKeyUpdate(int key, bool isDown); 102 | virtual void onMouseUpdate(char mousebutton, char isdown, __int16 mouseX, __int16 mouseY, __int16 relativeMovementX, __int16 relativeMovementY); 103 | virtual void onTrigger(); 104 | virtual void onEnable(); 105 | virtual void onDisable(); 106 | virtual bool onAttackBefore(class GameMode* ,class Actor*); // 返回值可以拦截该事件 107 | virtual void onAttackAfter(class GameMode* ,class Actor*); 108 | virtual bool useItem(class GameMode*,class ItemStack*); 109 | virtual bool useItemOn(class GameMode*, class ItemStack*, class ItemInstance*, vec3_ti* , uint8_t*, vec3_t* , class Block*); 110 | virtual bool onKnockback(class LocalPlayer*, vec3_t*); 111 | virtual void onActorTick(class Actor*); 112 | virtual void onActorSightTick(class Actor*); 113 | virtual void onPlayerTick(class Player*); // 这个在远程服务器只有本地玩家会调用 114 | virtual void onPlayerSightTick(class Player*); 115 | virtual void onServerPlayerTick(class ServerPlayer*); 116 | virtual void onLocalPlayerTick(class LocalPlayer*); 117 | virtual void onRemotePlayerTick(class RemotePlayer*); 118 | virtual void onLevelTick(class Level*); 119 | virtual void onstartLeaveGame(class Level*); 120 | virtual void onImGUIRender(); 121 | virtual void onInternalImGUIRender(); 122 | virtual bool onSendMessage(std::mcstring*); 123 | virtual void setEnabled(bool enabled); 124 | virtual void toggle(); 125 | virtual void onloadConfigFile(json& data); // 要求模块加载配置文件的时候将调用此方法 , 此时模块将data中的数据读取出来,应用到模块中 126 | virtual void onsaveConfigFile(json& data); // 要求保存配置文件时将调用此方法, 此时,模块将变量等要存储的信息保存到data中,全部结束后统一保存到文件 127 | virtual bool isEnabled(); 128 | virtual bool onSendPackToServer(class LoopbackPacketSender*, class Packet*); 129 | virtual void onDimensionChanged(class ClientInstance*); 130 | }; -------------------------------------------------------------------------------- /Mod/Modules/ModuleManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Module.h" 4 | #include 5 | #include "mcstring.h" 6 | 7 | class ModuleManager { 8 | private: 9 | std::vector moduleList = std::vector(); 10 | bool isInit = false; 11 | public: 12 | auto Init()->void; 13 | auto Disable()->void; 14 | auto IsInitialized()->bool; 15 | 16 | template 17 | auto GetModule()->TRet; 18 | 19 | auto GetAllModule()->std::vector; 20 | auto Moduleforeach(std::function)->void; 21 | 22 | public: 23 | auto onKeyUpdate(int, bool)->void; 24 | auto onMouseUpdate(char mousebutton, char isdown, __int16 mouseX, __int16 mouseY, __int16 relativeMovementX, __int16 relativeMovementY)->void; 25 | auto onTick(class GameMode*)->void; 26 | auto onAttackBefore(class GameMode* ,class Actor*) -> bool; // 返回值可以拦截该事件 27 | auto onAttackAfter(class GameMode* ,class Actor*)->void; // 返回值可以拦截该事件 28 | bool useItem(class GameMode*, class ItemStack*); 29 | bool useItemOn(class GameMode*, class ItemStack*, class ItemInstance*, vec3_ti*, uint8_t*, struct vec3_t*, class Block*); 30 | auto onKnockback(class LocalPlayer*, struct vec3_t*)->bool; // 返回值可以拦截该事件 31 | auto onActorTick(class Actor*)->void; // 暂时没找到相关函数 32 | auto onActorSightTick(class Actor*)->void; // 在本地玩家视野内的生物将会tick 来自Actor虚表函数:Actor::getShadowRadius Actor Mob会调用 但Player不会 33 | auto onPlayerTick(class Player*)->void; 34 | auto onPlayerSightTick(class Player*)->void; 35 | auto onServerPlayerTick(class ServerPlayer*)->void; 36 | auto onLocalPlayerTick(class LocalPlayer*)->void; 37 | auto onRemotePlayerTick(class RemotePlayer*)->void; 38 | auto onLevelTick(class Level*)->void; 39 | auto onstartLeaveGame(class Level*) -> void; 40 | auto onImGUIRender()->void; 41 | auto onSendMessage(std::mcstring*)->bool; 42 | auto onSendPacketToServer(class LoopbackPacketSender*, class Packet*) -> bool; 43 | auto onDimensionChanged(class ClientInstance*) -> void; 44 | auto onloadConfigFile(json& data)->void; 45 | auto onsaveConfigFile(json& data)->void; 46 | }; 47 | 48 | template 49 | auto ModuleManager::GetModule()->TRet { 50 | if (!IsInitialized()) 51 | return nullptr; 52 | for (auto pMod : moduleList) { 53 | if (auto pRet = dynamic_cast::type*>(pMod)) { 54 | //if (auto pRet = dynamic_cast(pMod)) { 55 | return pRet; 56 | } 57 | } 58 | return nullptr; 59 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/AirJump.cpp: -------------------------------------------------------------------------------- 1 | #include "AirJump.h" 2 | #include "LocalPlayer.h" 3 | #include "ServerPlayer.h" 4 | #include "GameMode.h" 5 | #include "ActorCollision.h" 6 | 7 | #include "Game.h" 8 | #include "Logger.h" 9 | 10 | AirJump::AirJump() : Module(0, "AirJump", "空气跳") { 11 | 12 | } 13 | 14 | // GameMode::Tick 被优化内联 15 | auto AirJump::onTick(GameMode* gm)->void { 16 | if (isEnabled()) { 17 | LocalPlayer* lp = gm->GetLocalPlayer(); 18 | if (lp != nullptr) { 19 | //lp->getMovementProxy()->setOnGround(true); 20 | } 21 | } 22 | } 23 | 24 | 25 | auto AirJump::onLocalPlayerTick(LocalPlayer* lp)->void 26 | { 27 | if (isEnabled()) { 28 | //lp->getMovementProxy()->setOnGround(true); 29 | lp->getActorCollision()->setOnGround(true); 30 | auto lsp = Game::GetLocalServerPlayer(); 31 | if (lsp) { 32 | lsp->getActorCollision()->setOnGround(true); 33 | } 34 | } 35 | } 36 | 37 | auto AirJump::onloadConfigFile(json& data)->void { 38 | setEnabled(config::readDataFromJson(data, "enable", false)); 39 | } 40 | auto AirJump::onsaveConfigFile(json& data)->void { 41 | data["enable"] = isEnabled(); 42 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/AirJump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class AirJump : public Module { 5 | public: 6 | AirJump(); 7 | 8 | public: 9 | virtual auto onTick(class GameMode*)->void override; 10 | virtual auto onLocalPlayerTick(class LocalPlayer*)->void override; 11 | virtual auto onloadConfigFile(json& data)->void override; 12 | virtual auto onsaveConfigFile(json& data)->void override; 13 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/ArmsLength.cpp: -------------------------------------------------------------------------------- 1 | #include "ArmsLength.h" 2 | #include "../../Utils/Logger.h" 3 | 4 | /* 5 | * 需要说明: (函数原理, 判断是否创造模式->攻击距离比较7或比较3-> 比较生存攻击距离是否小于等于3 6 | * 原来的方案是直接修改 这个3为指定的数 7 | * 但新版 这个3有好多地方在用, 如果修改会同时影响多个地方 8 | * 于是只能退而求其次, 修改实现逻辑, 判断如果不是创造, 直接跳到处理攻击的地方(原版是跳到判断攻击距离3), 而原版的前一步就是越过这个判断 9 | */ 10 | 11 | // 这里修改的地址的数, 有很多地方共用, 比如除了这里,还有划船速度也在使用, 检查摔落高度也在使用 12 | ArmsLength::ArmsLength() : Module(VK_F10, "ArmsLength", "修改玩家攻击距离") { 13 | setcontrolkeysbind({ VK_SHIFT }); 14 | auto sigOffset = FindSignature("84 C0 74 ? F3 44 0F 5D 3D ? ? ? ? EB ? F3 0F"); 15 | if (sigOffset == 0x00) { 16 | logF("[ArmsLength::ArmsLength] [error] FindSignature sigOffset NoFound"); 17 | return; 18 | } 19 | // new 20 | jumpaddr = reinterpret_cast(sigOffset + 3); 21 | sJumpaddr = *jumpaddr; 22 | //auto offset = *reinterpret_cast(sigOffset + 52); 23 | //arms = reinterpret_cast(sigOffset + 56 + offset);//指向玩家攻击距离的指针 52(22) 56(56-30=26) 24 | //setEnabled(true); //默认开启 25 | 26 | } 27 | 28 | auto ArmsLength::onEnable()->void { 29 | DWORD old_Page; 30 | bool b = VirtualProtect(jumpaddr, sizeof(BYTE), PAGE_EXECUTE_READWRITE, &old_Page); 31 | if (b) { 32 | *jumpaddr = sJumpaddr - 2; 33 | VirtualProtect(jumpaddr, sizeof(BYTE), old_Page, &old_Page); 34 | } 35 | 36 | 37 | //DWORD old_Page; 38 | //bool b = VirtualProtect(arms, sizeof(float), PAGE_READWRITE, &old_Page); 39 | //if (b) { 40 | // *arms = distance; 41 | // VirtualProtect(arms, sizeof(float), old_Page, &old_Page); 42 | //} 43 | } 44 | 45 | auto ArmsLength::onDisable()->void { 46 | //长臂管辖 47 | 48 | // new 49 | DWORD old_Page; 50 | bool b = VirtualProtect(jumpaddr, sizeof(BYTE), PAGE_EXECUTE_READWRITE, &old_Page); 51 | if (b) { 52 | *jumpaddr = sJumpaddr; 53 | VirtualProtect(jumpaddr, sizeof(BYTE), old_Page, &old_Page); 54 | } 55 | 56 | //DWORD old_Page; 57 | //bool b = VirtualProtect(arms, sizeof(float), PAGE_READWRITE, &old_Page); 58 | //if (b) { 59 | // *arms = 3.0f; 60 | // VirtualProtect(arms, sizeof(float), old_Page, &old_Page); 61 | //} 62 | } 63 | 64 | auto ArmsLength::isEnabled()->bool { 65 | if (!jumpaddr) return false; 66 | return *jumpaddr != sJumpaddr; 67 | } 68 | 69 | auto ArmsLength::onloadConfigFile(json& data)->void { 70 | setEnabled(config::readDataFromJson(data, "enable", true)); 71 | //distance = config::readDataFromJson(data, "distance", 7.f); 72 | } 73 | auto ArmsLength::onsaveConfigFile(json& data)->void { 74 | data["enable"] = isEnabled(); 75 | //data["distance"] = distance; 76 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/ArmsLength.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class ArmsLength : public Module { 5 | public: 6 | ArmsLength(); 7 | 8 | private: 9 | //float* arms = nullptr; 10 | //float distance = 7; 11 | 12 | 13 | BYTE sJumpaddr = 0; // 未作修改是jmp地址的值,以用作还原 14 | BYTE* jumpaddr = nullptr; 15 | public: 16 | virtual auto onEnable()->void override; 17 | virtual auto onDisable()->void override; 18 | virtual auto isEnabled()->bool override; 19 | virtual auto onloadConfigFile(json& data)->void override; 20 | virtual auto onsaveConfigFile(json& data)->void override; 21 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/BioRadar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | 5 | class BioRadar : public Module { 6 | public: 7 | BioRadar(); 8 | private: 9 | struct PlayerMapInfo; 10 | std::unordered_map playerlist; 11 | 12 | //雷达的地图的边长 像素 13 | float radarSide = 200.f; 14 | //游戏中距离与屏幕像素的缩放关系 15 | int roomscale = 2; 16 | //雷达与屏幕水平边缘的距离 具体是左还是右取决于 sideDirectionLeft 17 | float marginx = 100.f; 18 | //雷达与屏幕垂直边缘的距离 具体是上还是下取决于 sideDirectionTop 19 | float marginy = 100.f; 20 | //是否靠向屏幕左边,false表示靠向屏幕右边 21 | bool sideDirectionLeft = false; 22 | //是否靠向屏幕上边,false表示靠向屏幕下边 23 | bool sideDirectionTop = false; 24 | 25 | public: 26 | virtual auto onImGUIRender() -> void override; 27 | virtual auto onstartLeaveGame(class Level*) -> void override; 28 | virtual auto onPlayerTick(class Player*)->void override; // 远程玩家tick不好使 29 | virtual auto onDimensionChanged(class ClientInstance*) -> void override; 30 | virtual auto onloadConfigFile(json& data) -> void override; 31 | virtual auto onsaveConfigFile(json& data) -> void override; 32 | 33 | private: 34 | 35 | void renderMapBg(struct ImVec2 radarLeftTop); 36 | 37 | /** 38 | * @brief 处理列表中的玩家绘制,或移除 39 | * @param lpPos 本地玩家位置 40 | * @param lpRot 本地玩家视角 41 | * @param radarLeftTop 地图的左上角位置 42 | * @return 43 | */ 44 | void drawListPlayer(vec3_t lpPos, vec2_t lpRot, struct ImVec2 radarLeftTop); 45 | 46 | struct ImVec2 getRadarLeftTop(vec2_t screen); 47 | 48 | /** 49 | * @brief 根据玩家向量和玩家视角计算该玩家应该在地图上显示的位置 50 | * @param xdpos 本地玩家到目标玩家的向量 51 | * @param lprot 本地玩家的视角 52 | * @return 应该在小地图上显示的位置 53 | */ 54 | vec2_t getMapPosition(vec3_t xdpos, vec2_t lprot); 55 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/ChangeGameMode.cpp: -------------------------------------------------------------------------------- 1 | #include "ChangeGameMode.h" 2 | //程序模块 3 | #include "Game.h" 4 | //SDK 5 | #include "ClientInstance.h" 6 | #include "LocalPlayer.h" 7 | 8 | ChangeGameMode::ChangeGameMode() : Module(0, "ChangeGameMode", "切换游戏模式,开启后可使用快捷键(快捷键仅地图游戏界面有效)") { 9 | //SetKeyMode(KeyMode::Trigger); 10 | 11 | AddButtonUIEvent("生存[X]", false, []() { 12 | if (Game::Cinstance) { 13 | auto lp = Game::Cinstance->getCILocalPlayer(); 14 | if (lp) { 15 | lp->setPlayerGameType(0); 16 | } 17 | } 18 | }); 19 | AddButtonUIEvent("创造[C]", true, []() { 20 | if (Game::Cinstance) { 21 | auto lp = Game::Cinstance->getCILocalPlayer(); 22 | if (lp) { 23 | lp->setPlayerGameType(1); 24 | } 25 | } 26 | }); 27 | AddButtonUIEvent("冒险[V]", true, []() { 28 | if (Game::Cinstance) { 29 | auto lp = Game::Cinstance->getCILocalPlayer(); 30 | if (lp) { 31 | lp->setPlayerGameType(2); 32 | } 33 | } 34 | }); 35 | AddButtonUIEvent("旁观[N]", true, []() { 36 | if (Game::Cinstance) { 37 | auto lp = Game::Cinstance->getCILocalPlayer(); 38 | if (lp) { 39 | lp->setPlayerGameType(6); 40 | } 41 | } 42 | }); 43 | AddButtonUIEvent("默认[M]", true, []() { 44 | if (Game::Cinstance) { 45 | auto lp = Game::Cinstance->getCILocalPlayer(); 46 | if (lp) { 47 | lp->setPlayerGameType(5); 48 | } 49 | } 50 | }); 51 | 52 | } 53 | 54 | auto ChangeGameMode::onKeyUpdate(int key, bool isdown) -> void 55 | { 56 | if (isEnabled() && isdown && Game::Cinstance) { 57 | auto screen = Game::Cinstance->getTopScreenName().to_string(); 58 | if (screen.rfind("hud_screen") != std::string::npos) { 59 | auto lp = Game::Cinstance->getCILocalPlayer(); 60 | if (lp) { 61 | if (key == 'X') { 62 | // TUDO 生存 63 | lp->setPlayerGameType(0); 64 | } 65 | else if (key == 'C') { 66 | // TUDO: 67 | lp->setPlayerGameType(1); 68 | } 69 | else if (key == 'V') { 70 | // TUDO: 71 | lp->setPlayerGameType(2); 72 | } 73 | else if (key == 'N') { 74 | // TUDO: 75 | lp->setPlayerGameType(6); 76 | } 77 | else if (key == 'M') { 78 | // TUDO: 79 | lp->setPlayerGameType(5); 80 | } 81 | } 82 | } 83 | } 84 | } 85 | 86 | auto ChangeGameMode::onloadConfigFile(json& data)->void { 87 | setEnabled(config::readDataFromJson(data, "enable", false)); 88 | } 89 | auto ChangeGameMode::onsaveConfigFile(json& data)->void { 90 | data["enable"] = isEnabled(); 91 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/ChangeGameMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Module.h" 4 | 5 | class ChangeGameMode : public Module { 6 | public: 7 | ChangeGameMode(); 8 | 9 | virtual auto onKeyUpdate(int key, bool isdown) -> void override; 10 | virtual auto onloadConfigFile(json& data) -> void override; 11 | virtual auto onsaveConfigFile(json& data) -> void override; 12 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/Debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class Debug : public Module { 5 | public: 6 | Debug(); 7 | private: 8 | 9 | public: 10 | bool SynchronousD3D12Render_ImGui = false; 11 | bool GameMode_attack_Print = false; 12 | bool GameMode_attack_UseItem = false; 13 | 14 | public: 15 | virtual auto onImGUIRender() -> void override; 16 | virtual auto onKeyUpdate(int, bool) -> void override; 17 | virtual auto onSendPackToServer(class LoopbackPacketSender*, class Packet*) -> bool; 18 | virtual auto onInternalImGUIRender() -> void override; 19 | virtual auto onloadConfigFile(json& data) -> void override; 20 | virtual auto onsaveConfigFile(json& data) -> void override; 21 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/FastViewPerspective.cpp: -------------------------------------------------------------------------------- 1 | #include "FastViewPerspective.h" 2 | #include "../../Utils/Game.h" 3 | #include "../../Utils/Utils.h" 4 | 5 | #include "imgui.h" 6 | 7 | #include "GameMode.h" 8 | #include "LocalPlayer.h" 9 | 10 | 11 | FastViewPerspective::FastViewPerspective() : Module(VK_F9, "FastViewPerspective", "快速预览第二人称视角") { 12 | //setEnabled(true); 13 | AddBoolUIValue("切换人称视角时隐藏自己", &hide); 14 | } 15 | 16 | auto FastViewPerspective::getBindKeyName()->std::string { 17 | //ret : CTRL + SHIFT + F 18 | std::string name = "(鼠标后退键) "; 19 | name += Module::getBindKeyName(); 20 | return name; 21 | } 22 | 23 | auto FastViewPerspective::onInternalImGUIRender() -> void 24 | { 25 | ImGui::Text("选择该功能触发时展示的人称视角"); 26 | ImGui::RadioButton("第一人称", &ViewPerspective, 0); 27 | ImGui::SameLine(); 28 | ImGui::RadioButton("第二人称", &ViewPerspective, 1); 29 | ImGui::SameLine(); 30 | ImGui::RadioButton("第三人称", &ViewPerspective, 2); 31 | 32 | } 33 | 34 | 35 | auto FastViewPerspective::isToggle()->bool { 36 | return Game::IsMouseDown(VK_XBUTTON1) && !Utils::isCursorVisible(); 37 | } 38 | 39 | auto FastViewPerspective::getViewPerspective(int source) -> int 40 | { 41 | if (isToggle()) { 42 | return ViewPerspective; 43 | } 44 | return source; 45 | } 46 | 47 | auto FastViewPerspective::Hide() -> bool 48 | { 49 | return hide; 50 | } 51 | 52 | auto FastViewPerspective::onloadConfigFile(json& data)->void { 53 | setEnabled(config::readDataFromJson(data, "enable", true)); 54 | ViewPerspective = config::readDataFromJson(data, "ViewPerspective", 2); 55 | hide = config::readDataFromJson(data, "Hide", false); 56 | } 57 | auto FastViewPerspective::onsaveConfigFile(json& data)->void { 58 | data["enable"] = isEnabled(); 59 | data["ViewPerspective"] = ViewPerspective; 60 | data["Hide"] = hide; 61 | } 62 | -------------------------------------------------------------------------------- /Mod/Modules/Modules/FastViewPerspective.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class FastViewPerspective : public Module { 5 | public: 6 | FastViewPerspective(); 7 | 8 | private: 9 | int ViewPerspective = 2; 10 | bool hide = false; 11 | 12 | public: 13 | auto isToggle()->bool; 14 | auto getViewPerspective(int source) -> int; 15 | auto Hide() -> bool; 16 | 17 | public: 18 | virtual auto getBindKeyName()->std::string override; 19 | virtual auto onInternalImGUIRender() -> void override; 20 | virtual auto onloadConfigFile(json& data)->void override; 21 | virtual auto onsaveConfigFile(json& data)->void override; 22 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/FreeCamera.cpp: -------------------------------------------------------------------------------- 1 | #include "FreeCamera.h" 2 | 3 | #include "../../Hook/Hook.h" 4 | #include "Logger.h" 5 | 6 | #include "Game.h" 7 | #include "../ModuleManager.h" 8 | 9 | #include "LocalPlayer.h" 10 | 11 | struct CameraViewInfo 12 | { 13 | vec3_t pos; 14 | bool customizePos; 15 | BYTE unknowbyte_2[3]; 16 | vec2_t rot; 17 | }; 18 | 19 | using Fn_LockCameraTick = void* (__fastcall*)(void*, unsigned int); //*(bool*)(ret + 4 byte) 20 | using Fn_setCameraPosTick = void* (__fastcall*)(void*, void*, void*); 21 | using Fn_getCameraPosPtr = CameraViewInfo * (__fastcall*)(void*, DWORD*); // 这不是Hook 22 | 23 | Fn_LockCameraTick LockCameraTickcall; 24 | Fn_setCameraPosTick setCameraPosTickcall; 25 | // call 不是Hook后的call 26 | Fn_getCameraPosPtr getCameraPos; 27 | 28 | static uintptr_t lockCameraTickoffset = 0; 29 | static uintptr_t setCameraPosTickoffset = 0; 30 | 31 | bool FreeCamera::UnlockCamera = false; 32 | bool DebugPrint = false; 33 | float speed = 0.1f; 34 | 35 | 36 | 37 | // a1 不变 a2 不变 ret 变 38 | void* FreeCamera::_LockCameraTick(void* a1, unsigned int a2) { 39 | auto ret = LockCameraTickcall(a1, a2); 40 | 41 | static auto fc = Game::GetModuleManager()->GetModule(); 42 | 43 | if (fc && fc->isEnabled() && UnlockCamera) { 44 | if (ret) { 45 | *(bool*)ret = true; // 相当于运行了 /camera CNGEGE set minecraft:free 46 | *((bool*)ret + 4) = true; // 必须运行一次命令 /camera CNGEGE set minecraft:free pos ~ ~ ~ 设置位置 才有效 47 | } 48 | if(DebugPrint) logF_Debug("FreeCamera::_LockCameraTick a1:%llX, a2:%u, ret:%llX", a1, a2, ret); 49 | } 50 | return ret; 51 | } 52 | 53 | // a1 退出存档是不变的 a2 变, a3 不变 54 | void* FreeCamera::_setCameraPosTick(void* a1, void* a2, void* a3) { 55 | //setCameraPosTickcall 56 | static auto fc = Game::GetModuleManager()->GetModule(); 57 | if (fc && fc->isEnabled() && UnlockCamera) { 58 | auto posinfo = getCameraPos(**(void***)a1, (DWORD*)((uintptr_t)a1 + 8)); 59 | 60 | static auto lp = Game::Cinstance->getCILocalPlayer(); 61 | if (lp && posinfo) { 62 | posinfo->rot = *lp->getRotationEx(); // 必须执行一次 /camera CNGEGE set minecraft:free rot 50 50 设置方向的命令才有效 posinfo才不为0 63 | posinfo->customizePos = true; 64 | auto screen = Game::Cinstance->getTopScreenName().to_string(); 65 | if (screen.rfind("hud_screen") != std::string::npos) { 66 | if (Game::IsKeyDown(VK_UP)) { 67 | posinfo->pos.x -= speed; 68 | } 69 | if (Game::IsKeyDown(VK_DOWN)) { 70 | posinfo->pos.x += speed; 71 | } 72 | if (Game::IsKeyDown(VK_LEFT)) { 73 | posinfo->pos.z += speed; 74 | } 75 | if (Game::IsKeyDown(VK_RIGHT)) { 76 | posinfo->pos.z -= speed; 77 | } 78 | if (Game::IsKeyDown(VK_SPACE)) { 79 | posinfo->pos.y += speed; 80 | } 81 | if (Game::IsKeyDown(VK_SHIFT)) { 82 | posinfo->pos.y -= speed; 83 | } 84 | } 85 | } 86 | 87 | if(DebugPrint) logF_Debug("FreeCamera::_setCameraPosTick a1:%llX, a2:%llX, a3:%llX, **a1:%llX", a1, a2 ,a3, **(void***)a1); 88 | } 89 | return setCameraPosTickcall(a1, a2, a3); 90 | } 91 | 92 | FreeCamera::FreeCamera() : Module(0, "FreeCamera", "自由相机控制") 93 | { 94 | auto memcodeA1 = "E8 ? ? ? ? 48 85 C0 74 ? 80 78 04 00 74 ? 4C"; // 1.20.32.03 95 | auto memcodeA2 = "E8 ? ? ? ? 48 8B F8 48 85 C0 0F 84 ? ? ? ? 80 78 ? 00 0F 84 ? ? ? ? 8B"; // 1.20.32.03 96 | auto memcodeA3 = "E8 ? ? ? ? 48 8B D8 48 85 C0 0F 84 ? ? ? ? 48 89 74 24 ? 4C"; // 1.20.32.03 97 | 98 | // 找第一个Hookcall 99 | lockCameraTickoffset = FindSignature(memcodeA1); 100 | if (!lockCameraTickoffset) lockCameraTickoffset = FindSignature(memcodeA2); 101 | if (!lockCameraTickoffset) lockCameraTickoffset = FindSignature(memcodeA3); 102 | if (!lockCameraTickoffset) { 103 | logF("[FreeCamera::FreeCamera] lockCameraTickoffset 特征码失效"); 104 | return; 105 | } 106 | lockCameraTickoffset = Utils::FuncFromSigOffset(lockCameraTickoffset, 1); 107 | 108 | // 找第二个Hookcall 109 | auto memcodeB1 = "48 89 5C 24 ? 57 48 83 EC ? 48 8B 01 48 8B FA 48 8D"; // 1.20.32.03 110 | setCameraPosTickoffset = FindSignature(memcodeB1); 111 | if (!setCameraPosTickoffset) { 112 | logF("[FreeCamera::FreeCamera] setCameraPosTickoffset 特征码失效"); 113 | return; 114 | } 115 | 116 | // 找第三个call 117 | auto getCameraPosPtrCall = Utils::FindSignatureRelay(setCameraPosTickoffset, "E8", 100); 118 | if (!getCameraPosPtrCall) { 119 | logF("[FreeCamera::FreeCamera] 在setCameraPosTickoffset指针内查找 getCameraPosPtrCall 失败, 100 字节内 没有 E8 汇编码"); 120 | return; 121 | } 122 | getCameraPos = Utils::FuncFromSigOffset(getCameraPosPtrCall, 1); 123 | 124 | // Hook 125 | MH_CreateHookEx((LPVOID)lockCameraTickoffset, &FreeCamera::_LockCameraTick, &LockCameraTickcall); 126 | MH_CreateHookEx((LPVOID)setCameraPosTickoffset, &FreeCamera::_setCameraPosTick, &setCameraPosTickcall); 127 | 128 | 129 | AddBoolUIValue("解绑相机(Debug)", &UnlockCamera); 130 | AddBoolUIValue("输出Debug信息", &DebugPrint); 131 | AddFloatUIValue("设置相机移动速度", &speed, 0.01f, 5.f); 132 | } 133 | 134 | FreeCamera::~FreeCamera() { 135 | // 关闭Hook 136 | if (lockCameraTickoffset) MH_DisableHook((LPVOID)lockCameraTickoffset); 137 | if (setCameraPosTickoffset) MH_DisableHook((LPVOID)setCameraPosTickoffset); 138 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/FreeCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class FreeCamera : public Module { 5 | public: 6 | FreeCamera(); 7 | ~FreeCamera(); 8 | private: 9 | static void* _LockCameraTick(void* a1, unsigned int a2); 10 | static void* _setCameraPosTick(void* a1, void* a2, void* a3); 11 | 12 | public: 13 | 14 | static bool UnlockCamera; 15 | 16 | public: 17 | 18 | //virtual void onKeyUpdate(int key, bool isDown) override; 19 | }; 20 | -------------------------------------------------------------------------------- /Mod/Modules/Modules/GameTimeLock.cpp: -------------------------------------------------------------------------------- 1 | #include "GameTimeLock.h" 2 | #include "GameMode.h" 3 | #include "LocalPlayer.h" 4 | #include "Level.h" 5 | #include "Game.h" 6 | 7 | GameTimeLock::GameTimeLock() : Module(0, "GameTimeLock", "将游戏时间固定到一个设置的时间,不会改变真实时间") { 8 | AddIntUIValue("时间", &time, 0, 1000000,true); 9 | AddButtonUIEvent("清晨", false, [this]() { 10 | time = 0; 11 | if (Game::localplayer->isValid() && Game::localplayer->getLevel()) { 12 | Game::localplayer->getLevel()->setTime(time); 13 | } 14 | }); 15 | AddButtonUIEvent("正午", true, [this]() { 16 | time = 6000; 17 | if (Game::localplayer->isValid() && Game::localplayer->getLevel()) { 18 | Game::localplayer->getLevel()->setTime(time); 19 | } 20 | }); 21 | AddButtonUIEvent("傍晚", true, [this]() { 22 | time = 12000; 23 | if (Game::localplayer->isValid() && Game::localplayer->getLevel()) { 24 | Game::localplayer->getLevel()->setTime(time); 25 | } 26 | }); 27 | AddButtonUIEvent("午夜", true, [this]() { 28 | time = 18000; 29 | if (Game::localplayer->isValid() && Game::localplayer->getLevel()) { 30 | Game::localplayer->getLevel()->setTime(time); 31 | } 32 | }); 33 | } 34 | 35 | auto GameTimeLock::onTick(GameMode* gm)->void { 36 | return; 37 | auto lp = gm->GetLocalPlayer(); 38 | if (lp && lp->getLevel()) { 39 | if (isEnabled()) { 40 | lp->getLevel()->setTime(time); 41 | } 42 | else { 43 | time = lp->getLevel()->getTime(); 44 | } 45 | } 46 | } 47 | 48 | auto GameTimeLock::onLevelTick(Level* level)->void 49 | { 50 | if (isEnabled()) { 51 | level->setTime(time); 52 | } 53 | else { 54 | time = level->getTime(); 55 | } 56 | } 57 | 58 | auto GameTimeLock::onloadConfigFile(json& data)->void { 59 | setEnabled(config::readDataFromJson(data, "enable", false)); 60 | time = config::readDataFromJson(data, "time", 0); 61 | } 62 | 63 | auto GameTimeLock::onsaveConfigFile(json& data)->void { 64 | data["enable"] = isEnabled(); 65 | data["time"] = time; 66 | } 67 | -------------------------------------------------------------------------------- /Mod/Modules/Modules/GameTimeLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class GameTimeLock : public Module { 5 | public: 6 | GameTimeLock(); 7 | public: 8 | int time = 0; 9 | public: 10 | virtual auto onTick(class GameMode*)->void override; 11 | virtual auto onLevelTick(class Level*)->void override; 12 | virtual auto onloadConfigFile(json& data)->void override; 13 | virtual auto onsaveConfigFile(json& data)->void override; 14 | 15 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/HitBox.cpp: -------------------------------------------------------------------------------- 1 | #include "HitBox.h" 2 | #include "Actor.h" 3 | #include "Player.h" 4 | #include "../Mod/Utils/Game.h" 5 | #include "../ModuleManager.h" 6 | #include "NoAttackFriend.h" 7 | 8 | HitBox::HitBox() : Module(0, "HitBox", "增大其他玩家的碰撞体积,更容易击中") { 9 | AddFloatUIValue("宽度", &width, 0, 5.f, true); 10 | AddFloatUIValue("高度", &height, 0, 5.f, true); 11 | } 12 | 13 | auto HitBox::isEnabled()->bool { 14 | return GETKEYSTATE(VK_CAPITAL); 15 | } 16 | 17 | auto HitBox::getBindKeyName()->std::string { 18 | return Utils::getKeybindName(VK_CAPITAL); 19 | } 20 | 21 | auto HitBox::onPlayerSightTick(Player* player)->void { 22 | if (!player->isPlayer()) { 23 | return; 24 | } 25 | //判断是否是玩家 大写锁定 26 | static NoAttackFriend* noAttackFriend = Game::GetModuleManager()->GetModule(); 27 | 28 | if (isEnabled()) { 29 | if (playerlist.find(player)==playerlist.end()) { 30 | if (noAttackFriend && noAttackFriend->isEnabled() && noAttackFriend->IsFriend(player)) { 31 | return; 32 | } 33 | playerlist[player] = player->getHitBox(); 34 | player->setHitBox(vec2_t(width, height)); 35 | } 36 | 37 | } 38 | else { 39 | for (auto& kv : playerlist) { 40 | if (kv.first == player) { 41 | player->setHitBox(kv.second); 42 | playerlist.erase(kv.first); 43 | return; 44 | } 45 | } 46 | } 47 | 48 | } 49 | 50 | auto HitBox::onstartLeaveGame(Level* _) -> void 51 | { 52 | playerlist.clear(); 53 | } 54 | 55 | auto HitBox::onDimensionChanged(ClientInstance* _) -> void 56 | { 57 | playerlist.clear(); 58 | } 59 | 60 | auto HitBox::onloadConfigFile(json& data)->void { 61 | //setEnabled(config::readDataFromJson(data, "enable", true)); 62 | width = config::readDataFromJson(data, "width", 5.f); 63 | height = config::readDataFromJson(data, "height", 3.f); 64 | } 65 | auto HitBox::onsaveConfigFile(json& data)->void { 66 | //data["enable"] = isEnabled(); 67 | data["width"] = width; 68 | data["height"] = height; 69 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/HitBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class HitBox : public Module { 5 | private: 6 | std::unordered_map playerlist; 7 | public: 8 | HitBox(); 9 | float width = 5.0f; 10 | float height = 3.0f; 11 | public: 12 | virtual auto isEnabled()->bool override; 13 | virtual auto getBindKeyName()->std::string override; 14 | virtual auto onPlayerSightTick(class Player*)->void override; 15 | virtual auto onstartLeaveGame(class Level*) -> void override; 16 | virtual auto onDimensionChanged(class ClientInstance*) -> void override; 17 | virtual auto onloadConfigFile(json& data)->void override; 18 | virtual auto onsaveConfigFile(json& data)->void override; 19 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/HivePeekABooXRay.cpp: -------------------------------------------------------------------------------- 1 | #include "HivePeekABooXRay.h" 2 | #include 3 | 4 | #include "AABB.h" 5 | #include "ClientInstance.h" 6 | #include "LocalPlayer.h" 7 | #include "BlockSource.h" 8 | #include "Dimension.h" 9 | #include "Block.h" 10 | #include "BlockLegacy.h" 11 | #include "Game.h" 12 | #include "../Render/Render.h" 13 | 14 | std::mutex removePlayer_mutex2; 15 | 16 | HivePeekABooXRay::HivePeekABooXRay() : Module(VK_F6, "HivePeekABooXRay", "TheHive躲猫猫专用透视") { 17 | setcontrolkeysbind({ VK_CONTROL }); 18 | AddBoolUIValue("从玩家名称中计算颜色", &colorFromName); 19 | AddBoolUIValue("启用中心线", &hasLine); 20 | AddBoolUIValue("中心线的颜色跟随玩家", &lineColorFromPlayer); 21 | //Color 22 | AddColorUIValue("玩家的方块颜色", &playerBoxColor); 23 | AddColorUIValue("玩家的中心线颜色", &playerLineColor); 24 | AddColorUIValue("玩家变成的方块颜色", &blockBoxColor); 25 | AddColorUIValue("方块的中心线颜色", &blockLineColor); 26 | 27 | AddButtonUIEvent("清除", false, [this]() { playerlist.clear(); std::lock_guard guard(removePlayer_mutex2); removePlyaerList.clear(); }); 28 | } 29 | 30 | 31 | struct HivePeekABooXRay::PlayerMapInfo { 32 | ImColor color; //应该显示的颜色 33 | vec3_t pos; 34 | vec3_ti footPos; 35 | AABB aabb; 36 | }; 37 | 38 | auto HivePeekABooXRay::onImGUIRender() -> void 39 | { 40 | if (!isEnabled()) return; 41 | auto drawList = ImGui::GetForegroundDrawList(); 42 | auto screen = Render::getScreen(); 43 | handlePlayerList(screen); 44 | renderBlock(screen); 45 | } 46 | 47 | auto HivePeekABooXRay::onstartLeaveGame(Level*) -> void 48 | { 49 | playerlist.clear(); 50 | 51 | std::lock_guard guard(removePlayer_mutex2); 52 | removePlyaerList.clear(); 53 | } 54 | 55 | auto HivePeekABooXRay::onPlayerTick(Player* player) -> void 56 | { 57 | if (!isEnabled()) { 58 | return; 59 | } 60 | if (!Game::Cinstance) { 61 | return; 62 | } 63 | if (player->isLocalPlayer()) { 64 | return; 65 | } 66 | LocalPlayer* lp = Game::Cinstance->getCILocalPlayer(); 67 | 68 | if (lp && lp->isValid()) { 69 | //获得本地玩家的位置视角相关信息 70 | //vec3_t* lpos = lp->getPosition(); 71 | //vec2_t* lrot = lp->getRotationEx(); 72 | vec3_t* pos = player->getPosition(); 73 | //获得 对方玩家对本地玩家的相对位置 即本地玩家对远程玩家的空间向量 74 | //vec3_t xdpos = pos->sub(*lpos); 75 | 76 | PlayerMapInfo pmi; 77 | pmi.pos = *pos; 78 | pmi.footPos = player->getFootPos(); 79 | pmi.aabb = *player->getAABB(); 80 | //pmi.x = mappos.x; pmi.z = mappos.y; 81 | 82 | auto name = player->getNameTag()->to_string().substr(0, 3); //章节号占两字节 83 | pmi.color = Utils::GetColorbyChar(name); 84 | 85 | playerlist[player] = pmi; 86 | } 87 | } 88 | 89 | auto HivePeekABooXRay::onDimensionChanged(ClientInstance* ci) -> void 90 | { 91 | playerlist.clear(); 92 | std::lock_guard guard(removePlayer_mutex2); 93 | removePlyaerList.clear(); 94 | } 95 | 96 | auto HivePeekABooXRay::onLevelTick(Level* level) -> void 97 | { 98 | if (!isEnabled()) return; 99 | if (!Game::Cinstance) return; 100 | auto lp = Game::Cinstance->getCILocalPlayer(); 101 | if (!lp) return; 102 | 103 | for (auto iter = removePlyaerList.begin(); iter != removePlyaerList.end(); ++iter) 104 | { 105 | auto dim = lp->getDimensionConst(); 106 | if (!dim) continue; 107 | BlockSource* bs = dim->getBlockSourceEx(); 108 | if (!bs) continue; 109 | vec3_ti playerBlock = (*iter).footPos; 110 | if (bs->getBlock(&playerBlock)->isAir()) { 111 | std::lock_guard guard(removePlayer_mutex2); 112 | removePlyaerList.erase(iter); 113 | break; 114 | } 115 | } 116 | } 117 | 118 | auto HivePeekABooXRay::onloadConfigFile(json& data) -> void 119 | { 120 | setEnabled(config::readDataFromJson(data, "enable", false)); 121 | } 122 | 123 | auto HivePeekABooXRay::onsaveConfigFile(json& data) -> void 124 | { 125 | data["enable"] = isEnabled(); 126 | } 127 | 128 | void HivePeekABooXRay::handlePlayerList(vec2_t screen) { 129 | auto drawList = ImGui::GetForegroundDrawList(); 130 | for (auto& kv : playerlist) { 131 | 132 | if (kv.first->isValid()) { 133 | if (!kv.first->isRemovedEx()) { 134 | ImColor boxColor = kv.second.color; 135 | if (!colorFromName) { 136 | boxColor = playerBoxColor; 137 | } 138 | auto centerPos = Render::RenderAABB(kv.second.aabb, boxColor); 139 | if (centerPos && hasLine) { 140 | ImColor lineColor = kv.second.color; 141 | if (!lineColorFromPlayer) { 142 | lineColor = playerLineColor; 143 | } 144 | drawList->AddLine({ screen.x / 2, screen.y / 2 }, { centerPos->x,centerPos->y }, lineColor); 145 | } 146 | } 147 | else { 148 | std::lock_guard guard(removePlayer_mutex2); 149 | PlayerMapInfo removePlayer = kv.second; 150 | removePlyaerList.push_back(removePlayer); 151 | playerlist.erase(kv.first); 152 | break; 153 | } 154 | } 155 | else { 156 | playerlist.erase(kv.first); 157 | break; 158 | } 159 | } 160 | } 161 | 162 | void HivePeekABooXRay::renderBlock(vec2_t screen) { 163 | auto drawList = ImGui::GetForegroundDrawList(); 164 | std::lock_guard guard(removePlayer_mutex2); 165 | for (auto iter = removePlyaerList.begin(); iter != removePlyaerList.end(); ++iter) { 166 | std::optional centerPos = Render::RenderBlockBox((*iter).footPos, blockBoxColor); 167 | if (centerPos && hasLine) { 168 | ImColor lineColor = blockLineColor; 169 | if (lineColorFromPlayer) { 170 | lineColor = blockBoxColor; 171 | } 172 | drawList->AddLine({ screen.x / 2, screen.y / 2 }, { centerPos->x,centerPos->y }, blockLineColor, 1.5f); 173 | } 174 | } 175 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/HivePeekABooXRay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | #include "imgui.h" 5 | 6 | class HivePeekABooXRay : public Module 7 | { 8 | private: 9 | bool colorFromName = true; 10 | bool hasLine = true; 11 | bool lineColorFromPlayer = true; 12 | ImColor playerBoxColor = ImColor(255, 255, 255, 255); 13 | ImColor playerLineColor = ImColor(255, 255, 255, 255); 14 | ImColor blockBoxColor = ImColor(241, 196, 15, 255); 15 | ImColor blockLineColor = ImColor(241, 196, 15, 255); 16 | 17 | 18 | struct PlayerMapInfo; 19 | std::unordered_map playerlist; 20 | std::vector removePlyaerList; 21 | 22 | public: 23 | HivePeekABooXRay(); 24 | private: 25 | /** 26 | * @brief 处理玩家列表,渲染透视,处理移除的玩家到 removePlyaerList 27 | * @param screen 28 | */ 29 | void handlePlayerList(vec2_t screen); 30 | 31 | /** 32 | * @brief 渲染方块 33 | * @param screen 34 | */ 35 | void renderBlock(vec2_t screen); 36 | 37 | public: 38 | virtual auto onImGUIRender() -> void override; 39 | virtual auto onstartLeaveGame(class Level*) -> void override; 40 | virtual auto onPlayerTick(class Player*) -> void override; // 远程玩家tick不好使 41 | virtual auto onDimensionChanged(class ClientInstance*) -> void override; 42 | virtual auto onLevelTick(Level* level) -> void override; 43 | virtual auto onloadConfigFile(json& data) -> void override; 44 | virtual auto onsaveConfigFile(json& data) -> void override; 45 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/HiveTreasurePos.cpp: -------------------------------------------------------------------------------- 1 | #include "HiveTreasurePos.h" 2 | #include "../../Utils/Game.h" 3 | #include "Actor.h" 4 | #include "LocalPlayer.h" 5 | 6 | HiveTreasurePos::HiveTreasurePos() : Module(VK_F7, "HiveTreasurePos", "在 HIVE 起床战争中,把附近小的宝箱碰撞箱拉过来") { 7 | SetKeyMode(KeyMode::Switch); 8 | setcontrolkeysbind({ VK_SHIFT }); 9 | } 10 | 11 | auto HiveTreasurePos::onActorTick(Actor* actor)->void { 12 | if (Game::localplayer == nullptr) { 13 | return; 14 | } 15 | 16 | if (isEnabled() && Game::localplayer->isSneaking()) { 17 | if (actor->getEntityTypeId() == ActorType::Hive_Treasure) { 18 | if (actor->getHitBox().x == 0.800000f) { //0.800000 两边小宝箱, 2.400000 中间大宝箱 类型ID都是一样的 19 | vec3_t lppos(Game::localplayer->getPosition()->x, Game::localplayer->getPosEx().y, Game::localplayer->getPosition()->z); 20 | if (lppos.CoordinateDistance(*actor->getPosition()) <= 5.f) { 21 | actor->setPos(&lppos); 22 | } 23 | } 24 | } 25 | } 26 | } 27 | 28 | auto HiveTreasurePos::onloadConfigFile(json& data)->void { 29 | setEnabled(config::readDataFromJson(data, "enable", false)); 30 | } 31 | auto HiveTreasurePos::onsaveConfigFile(json& data)->void { 32 | data["enable"] = isEnabled(); 33 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/HiveTreasurePos.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class HiveTreasurePos : public Module 5 | { 6 | public: 7 | HiveTreasurePos(); 8 | 9 | public: 10 | 11 | virtual auto onActorTick(class Actor* actor)->void override; 12 | virtual auto onloadConfigFile(json& data)->void override; 13 | virtual auto onsaveConfigFile(json& data)->void override; 14 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/HundredTimesMoreDrops.cpp: -------------------------------------------------------------------------------- 1 | #include "HundredTimesMoreDrops.h" 2 | 3 | HundredTimesMoreDrops::HundredTimesMoreDrops() : Module(0, "HundredTimesMoreDrops", "百倍掉落物品") { 4 | AddIntUIValue("掉落倍数", &multiple, 1, 200); 5 | AddBoolUIValue("仅本地玩家", &onlyLocalPlayer); 6 | } 7 | 8 | 9 | auto HundredTimesMoreDrops::onloadConfigFile(json& data)->void { 10 | setEnabled(config::readDataFromJson(data, "enable", false)); 11 | multiple = config::readDataFromJson(data, "multiple", 100); 12 | onlyLocalPlayer = config::readDataFromJson(data, "onlyLocalPlayer", false); 13 | } 14 | auto HundredTimesMoreDrops::onsaveConfigFile(json& data)->void { 15 | data["enable"] = isEnabled(); 16 | data["multiple"] = multiple; 17 | data["onlyLocalPlayer"] = onlyLocalPlayer; 18 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/HundredTimesMoreDrops.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class HundredTimesMoreDrops : public Module { 5 | public: 6 | HundredTimesMoreDrops(); 7 | 8 | public: 9 | int multiple = 100; 10 | bool onlyLocalPlayer = false; 11 | public: 12 | virtual auto onloadConfigFile(json& data) -> void override; 13 | virtual auto onsaveConfigFile(json& data) -> void override; 14 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/InstantDestroy.cpp: -------------------------------------------------------------------------------- 1 | #include "InstantDestroy.h" 2 | #include "../Mod/Utils/Game.h" 3 | #include "../SDK/GameMode.h" 4 | 5 | InstantDestroy::InstantDestroy() : Module(0, "InstantDestroy", "按下 CTRL + SHIFT 后破坏方块时瞬间破坏") { 6 | //setEnabled(true); 7 | } 8 | 9 | InstantDestroy::~InstantDestroy() { 10 | setEnabled(false); 11 | } 12 | 13 | auto InstantDestroy::getBindKeyName()->std::string { 14 | //ret : CTRL + SHIFT + F 15 | std::string name = Utils::getKeybindName(VK_SHIFT); 16 | name += "+"; 17 | name += Utils::getKeybindName(VK_CONTROL); 18 | return name; 19 | } 20 | 21 | 22 | auto InstantDestroy::onStartDestroyBlock(GameMode* gm, vec3_ti* Bpos, uint8_t* Face)->void { 23 | if (isEnabled() && Game::IsKeyDown(VK_SHIFT) && Game::IsKeyDown(VK_CONTROL)) { 24 | gm->destroyBlock(Bpos, Face); 25 | } 26 | } 27 | 28 | auto InstantDestroy::onloadConfigFile(json& data)->void { 29 | setEnabled(config::readDataFromJson(data, "enable", true)); 30 | } 31 | auto InstantDestroy::onsaveConfigFile(json& data)->void { 32 | data["enable"] = isEnabled(); 33 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/InstantDestroy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | 5 | class InstantDestroy : public Module { 6 | public: 7 | InstantDestroy(); 8 | ~InstantDestroy(); 9 | public: 10 | auto onStartDestroyBlock(GameMode* gm, vec3_ti* Bpos, uint8_t* Face)->void; 11 | 12 | virtual auto getBindKeyName()->std::string override; 13 | virtual auto onloadConfigFile(json& data)->void override; 14 | virtual auto onsaveConfigFile(json& data)->void override; 15 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/LockControlInput.cpp: -------------------------------------------------------------------------------- 1 | #include "LockControlInput.h" 2 | 3 | bool disableSignal = false; 4 | 5 | LockControlInput::LockControlInput() : Module(VK_F12, "LockControlInput", "锁定移动控制键") { 6 | setcontrolkeysbind({ VK_CONTROL }); 7 | 8 | AddBoolUIValue("锁定下蹲", &ControlKeyStatus.Sneak); 9 | AddBoolUIValue("锁定跳跃", &ControlKeyStatus.Jump); 10 | AddBoolUIValue("锁定疾跑", &ControlKeyStatus.Sprinting); 11 | AddBoolUIValue("锁定W", &ControlKeyStatus.W); 12 | AddBoolUIValue("锁定S", &ControlKeyStatus.S); 13 | AddBoolUIValue("锁定A", &ControlKeyStatus.A); 14 | AddBoolUIValue("锁定D", &ControlKeyStatus.D); 15 | } 16 | 17 | auto LockControlInput::onDisable() -> void{ 18 | disableSignal = true; 19 | } 20 | 21 | auto LockControlInput::onloadConfigFile(json& data)->void { 22 | //setEnabled(config::readDataFromJson(data, "enable", true)); 23 | ControlKeyStatus.Sneak = config::readDataFromJson(data, "ControlKeyStatus_Sneak", false); 24 | ControlKeyStatus.Jump = config::readDataFromJson(data, "ControlKeyStatus_Jump", false); 25 | ControlKeyStatus.Sprinting = config::readDataFromJson(data, "ControlKeyStatus_Sprinting", false); 26 | ControlKeyStatus.W = config::readDataFromJson(data, "ControlKeyStatus_W", false); 27 | ControlKeyStatus.S = config::readDataFromJson(data, "ControlKeyStatus_S", false); 28 | ControlKeyStatus.A = config::readDataFromJson(data, "ControlKeyStatus_A", false); 29 | ControlKeyStatus.D = config::readDataFromJson(data, "ControlKeyStatus_D", false); 30 | } 31 | auto LockControlInput::onsaveConfigFile(json& data)->void { 32 | //data["enable"] = isEnabled(); 33 | data["ControlKeyStatus_Sneak"] = ControlKeyStatus.Sneak; 34 | data["ControlKeyStatus_Jump"] = ControlKeyStatus.Jump; 35 | data["ControlKeyStatus_Sprinting"] = ControlKeyStatus.Sprinting; 36 | data["ControlKeyStatus_W"] = ControlKeyStatus.W; 37 | data["ControlKeyStatus_S"] = ControlKeyStatus.S; 38 | data["ControlKeyStatus_A"] = ControlKeyStatus.A; 39 | data["ControlKeyStatus_D"] = ControlKeyStatus.D; 40 | } 41 | 42 | auto LockControlInput::ControlTick(ControlKey* keyStatus)->void { 43 | if (isEnabled()) { 44 | if (ControlKeyStatus.Sneak) keyStatus->Sneak = ControlKeyStatus.Sneak; 45 | if (ControlKeyStatus.Jump) keyStatus->Jump = ControlKeyStatus.Jump; 46 | if (ControlKeyStatus.Sprinting) keyStatus->Sprinting = ControlKeyStatus.Sprinting; 47 | if (ControlKeyStatus.W) keyStatus->W = ControlKeyStatus.W; 48 | if (ControlKeyStatus.S) keyStatus->S = ControlKeyStatus.S; 49 | if (ControlKeyStatus.A) keyStatus->A = ControlKeyStatus.A; 50 | if (ControlKeyStatus.D) keyStatus->D = ControlKeyStatus.D; 51 | } 52 | else { 53 | if (disableSignal) { 54 | disableSignal = false; 55 | memset(keyStatus, '\0', 14); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/LockControlInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class LockControlInput : public Module { 5 | public: 6 | LockControlInput(); 7 | 8 | public: 9 | struct ControlKey 10 | { 11 | bool Sneak; // 潜行 12 | BYTE __unknowkey1; 13 | bool ProhibitionOfFloating; // 禁止上浮(在水中无法上浮和创造模式自动下沉) 14 | BYTE __unknowkey3; 15 | BYTE __unknowkey4; 16 | BYTE __unknowkey5; 17 | bool Jump; 18 | bool Sprinting; 19 | bool WA; // 向左前移动 20 | bool WD; // 向右前移动 21 | bool W; 22 | bool S; 23 | bool A; 24 | bool D; 25 | BYTE __unknowkey6[2]; 26 | BYTE __unknowkey7[16]; 27 | BYTE __unknowkey8[8]; 28 | float HorizontalRocker; // 水平的值(左右 左1 右-1 好像是只读 29 | float VerticalRocker; // 垂直的值 (前后 前1 后-1 好像是只读 30 | }; 31 | 32 | public: 33 | virtual auto onDisable() -> void override; 34 | virtual auto onloadConfigFile(json& data) -> void override; 35 | virtual auto onsaveConfigFile(json& data) -> void override; 36 | 37 | public: 38 | ControlKey ControlKeyStatus{}; 39 | void ControlTick(ControlKey*); 40 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/NoAttackFriend.cpp: -------------------------------------------------------------------------------- 1 | #include "NoAttackFriend.h" 2 | #include "Actor.h" 3 | #include "LocalPlayer.h" 4 | #include "ClientInstance.h" 5 | #include "../../Utils/Game.h" 6 | #include "../../Utils/Utils.h" 7 | 8 | NoAttackFriend::NoAttackFriend() : Module(VK_F4, "NoAttackFriend", "根据玩家名称的颜色识别玩家为队友时拦截攻击") { 9 | setcontrolkeysbind({ VK_SHIFT }); 10 | //colorbyte[0] = Utils::ANSItoUTF8(colorbyte[0].c_str()); 11 | } 12 | 13 | auto NoAttackFriend::IsFriend(Player* p)->bool { 14 | if (!Game::Cinstance) { 15 | return false; 16 | } 17 | auto lp = Game::Cinstance->getCILocalPlayer(); 18 | if (!lp) { 19 | return false; 20 | } 21 | 22 | auto name = std::string(p->getNameTag()->c_str()); 23 | auto myname = std::string(lp->getNameTag()->c_str()); 24 | 25 | auto name_first = name.substr(0, 2); 26 | auto myname_first = myname.substr(0, 2); 27 | if (name_first == colorbyte[0] && myname_first == colorbyte[0]) { //判断自己和对方名字是否是带有颜色 即§开头 28 | auto name_next = name.substr(2, 1); 29 | auto myname_next = myname.substr(2, 1); 30 | if (name_next == myname_next) { //判断(如果是)颜色(那)是否是一样 31 | for (int i = 1; i < 17; i++) { //判断符号后面是否接颜色,长度是定值 32 | if (colorbyte[i] == myname_next) { 33 | return true; 34 | } 35 | } 36 | } 37 | } 38 | return false; 39 | } 40 | 41 | //#include "../../Utils/Logger.h" 42 | auto NoAttackFriend::onAttackBefore(class GameMode* gm, Actor* actor)->bool { 43 | if (!isEnabled()) { 44 | return true; 45 | } 46 | { 47 | //暂时搁置 48 | //logF("myptr:%llX,myname:%s", Game::localplayer, Game::localplayer->getNameTag()->getText()); 49 | //logF("actorname:%s,actorptr:%llX,IsFriend:%d", actor->getNameTag()->getText(), actor, IsFriend((Player*)actor)); 50 | } 51 | if (!actor->isPlayerEx()) { 52 | return true; 53 | } 54 | 55 | return !IsFriend((Player*)actor); 56 | } 57 | 58 | auto NoAttackFriend::onloadConfigFile(json& data)->void { 59 | setEnabled(config::readDataFromJson(data, "enable", false)); 60 | } 61 | auto NoAttackFriend::onsaveConfigFile(json& data)->void { 62 | data["enable"] = isEnabled(); 63 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/NoAttackFriend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma execution_character_set("utf-8") 3 | #include "../Module.h" 4 | 5 | 6 | class NoAttackFriend : public Module 7 | { 8 | public: 9 | NoAttackFriend(); 10 | 11 | public: 12 | std::string colorbyte[17] = { "§","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; 13 | 14 | public: 15 | virtual auto onAttackBefore(class GameMode* gm,class Actor*)->bool override; 16 | 17 | auto IsFriend(class Player*)->bool; 18 | virtual auto onloadConfigFile(json& data)->void override; 19 | virtual auto onsaveConfigFile(json& data)->void override; 20 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/NoKnockback.cpp: -------------------------------------------------------------------------------- 1 | #include "NoKnockback.h" 2 | #include "Game.h" 3 | 4 | bool LongEnable = false; 5 | 6 | NoKnockback::NoKnockback() : Module(VK_F4, "NoKnockback", "按下快捷键后不会被击退") { 7 | setcontrolkeysbind({ VK_CONTROL }); 8 | AddBoolUIValue("开启后持续零击退,热键临时解除", &LongEnable); 9 | //SetKeyMode(KeyMode::Hold); 10 | } 11 | 12 | auto NoKnockback::getBindKeyName()->std::string { 13 | //ret : (CTRL) CTRL + F4 14 | std::string name = "(CTRL) "; 15 | name += Module::getBindKeyName(); 16 | return name; 17 | } 18 | 19 | auto NoKnockback::onKnockback(LocalPlayer* lp, vec3_t* v3)->bool { 20 | if (isEnabled()) { 21 | if (LongEnable) { 22 | return Game::IsKeyDown(VK_CONTROL); 23 | } 24 | else { 25 | return !Game::IsKeyDown(VK_CONTROL); 26 | } 27 | } 28 | return true; 29 | } 30 | 31 | auto NoKnockback::onloadConfigFile(json& data)->void { 32 | setEnabled(config::readDataFromJson(data, "enable", true)); 33 | } 34 | auto NoKnockback::onsaveConfigFile(json& data)->void { 35 | data["enable"] = isEnabled(); 36 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/NoKnockback.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class NoKnockback : public Module { 5 | public: 6 | NoKnockback(); 7 | 8 | public: 9 | virtual auto getBindKeyName()->std::string override; 10 | virtual auto onKnockback(class LocalPlayer*, struct vec3_t*)->bool override; 11 | virtual auto onloadConfigFile(json& data)->void override; 12 | virtual auto onsaveConfigFile(json& data)->void override; 13 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/RenderHealth.cpp: -------------------------------------------------------------------------------- 1 | #include "RenderHealth.h" 2 | #include "Actor.h" 3 | //#include "MinecraftUIRenderContext.h" 4 | //#include "mcstring.h" 5 | #include "imgui.h" 6 | #include "Game.h" 7 | 8 | #include 9 | 10 | RenderHealth::RenderHealth() : Module(VK_F10, "RenderHealth", "显示被攻击生物的血量和名字") { 11 | setcontrolkeysbind({ VK_CONTROL }); 12 | //setEnabled(true); 13 | AddFloatUIValue("UI显示时长", &actorTime, 1.f, 15.f, true, 0.1f); 14 | AddBoolUIValue("玩家名字渲染颜色(暂不可用)", &renderColor); 15 | } 16 | 17 | 18 | auto RenderHealth::onAttackAfter(class GameMode* gm,Actor* actor)->void { 19 | if (isEnabled()) { 20 | currentPlayerHealth = actor->getHealth(); 21 | std::string sname = actor->getNameTag()->to_string(); 22 | auto find = sname.find("\n"); 23 | if (find == -1) { 24 | currentPlayerName = sname; 25 | } 26 | else { 27 | currentPlayerName = sname.substr(0, find); 28 | } 29 | if (currentPlayerName.empty()) { 30 | currentPlayerTypeName = actor->getTypeName()->c_str(); 31 | } 32 | showtime = Utils::GetCuttentMillisecond() + actorTime * 1000; 33 | //tick = 400.f; 34 | //show = true; 35 | } 36 | return; 37 | } 38 | 39 | 40 | auto RenderHealth::onImGUIRender() -> void 41 | { 42 | if (isEnabled() && showtime) { 43 | 44 | float endTime = static_cast(*showtime - Utils::GetCuttentMillisecond()); 45 | if (endTime < 0.f) { 46 | showtime.reset(); 47 | return; 48 | } 49 | 50 | RECT rect{}; 51 | if (::GetWindowRect((HWND)Game::WindowsHandle, (LPRECT)&rect)) 52 | { 53 | auto drawList = ImGui::GetForegroundDrawList(); 54 | float rectwidth = (float)(rect.right - rect.left); 55 | float rectheight = (float)(rect.bottom - rect.top); 56 | 57 | 58 | std::string drawName; 59 | if (currentPlayerName.empty()) { 60 | drawName += "生物类型: "; 61 | drawName += currentPlayerTypeName; 62 | } 63 | else { 64 | drawName += "生物名字: "; 65 | drawName += currentPlayerName; 66 | } 67 | 68 | std::string drawHealth("生物血量: "); 69 | drawHealth += std::to_string(currentPlayerHealth); 70 | //ImGui::CalcTextSize() 71 | 72 | 73 | // 计算宽高 74 | float bgWidth = max(ImGui::CalcTextSize(drawName.c_str()).x, ImGui::CalcTextSize(drawHealth.c_str()).x) + 10.f; //150 75 | float bgHeight = 40; 76 | 77 | ImVec2 LTop = { rectwidth * 0.5f - bgWidth * 0.5f, rectheight * 0.75f }; 78 | 79 | // 绘制 80 | drawList->AddRectFilled(LTop, { LTop.x + bgWidth,LTop.y + bgHeight }, ImColor(0, 0, 0, 100)); 81 | 82 | // 计算UI剩余显示百分比 83 | float uiTimeLengthWidth = endTime / (actorTime * 1000) * bgWidth; 84 | drawList->AddRectFilled({ LTop.x, LTop.y - 2.f }, { LTop.x + uiTimeLengthWidth, LTop.y}, ImColor(194, 31, 48, 255)); 85 | 86 | drawList->AddText({ LTop.x + 5.f, LTop.y + 5.f }, ImColor(255, 255, 255, 255), drawName.c_str()); 87 | drawList->AddText({ LTop.x + 5.f, LTop.y + 20.f }, ImColor(255, 255, 255, 255), drawHealth.c_str()); 88 | 89 | } 90 | } 91 | } 92 | 93 | //auto RenderHealth::onRenderDetour(MinecraftUIRenderContext* ctx)->void { 94 | // if (show && isEnabled()) { 95 | // tick--; 96 | // if (tick <= 0) { 97 | // show = false; 98 | // return; 99 | // } 100 | // 101 | // RECT rect{}; 102 | // vec2_t bg_wh = vec2_t(130.f, 35.f); 103 | // if (::GetWindowRect((HWND)ImGui::GetMainViewport()->PlatformHandleRaw, (LPRECT)&rect)) { 104 | // float rectwidth = (float)(rect.right - rect.left); 105 | // showpos.x = (rectwidth - bg_wh.x) / 4.f; 106 | // //showpos.x = 230.f; 107 | // } 108 | // 109 | // UIColor bgcolor = UIColor(0, 0, 0, (tick < 60) ? tick : 60); 110 | // UIColor textcolor = UIColor(255, 255, 255, (tick < 255) ? tick : 255); 111 | // ctx->Fillshape(showpos, bg_wh, bgcolor); 112 | // 113 | // std::string drawName("Name: "); 114 | // drawName += currentPlayerName; 115 | // std::string drawHealth("Health: "); 116 | // drawHealth += std::to_string(currentPlayerHealth); 117 | // 118 | // ctx->Drawtext(vec2_t(showpos.x + 5.f, showpos.y + 5.f), &drawName, textcolor, 1.f); 119 | // ctx->Drawtext(vec2_t(showpos.x + 5.f, showpos.y + 20.f), &drawHealth, textcolor, 1.f); 120 | // ctx->flushText(0); 121 | // } 122 | //} 123 | 124 | 125 | auto RenderHealth::onloadConfigFile(json& data)->void { 126 | setEnabled(config::readDataFromJson(data, "enable", true)); 127 | actorTime = config::readDataFromJson(data, "UIactorTime", 5.f); 128 | renderColor = config::readDataFromJson(data, "renderColor", true); 129 | } 130 | auto RenderHealth::onsaveConfigFile(json& data)->void { 131 | data["enable"] = isEnabled(); 132 | data["UIactorTime"] = actorTime; 133 | data["renderColor"] = renderColor; 134 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/RenderHealth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | #include "../../Utils/HMath.h" 4 | 5 | class RenderHealth : public Module { 6 | public: 7 | RenderHealth(); 8 | 9 | private: 10 | // UI 11 | float actorTime = 5.f; 12 | bool renderColor = true; 13 | private: 14 | vec2_t showpos = vec2_t(230.f, 250.f); 15 | std::optional showtime; 16 | 17 | std::string currentPlayerName; 18 | std::string currentPlayerTypeName; 19 | float currentPlayerHealth = 0.f; 20 | 21 | public: 22 | virtual auto onAttackAfter(class GameMode* gm,class Actor*)->void override; 23 | virtual auto onImGUIRender() -> void override; 24 | virtual auto onloadConfigFile(json& data)->void override; 25 | virtual auto onsaveConfigFile(json& data)->void override; 26 | }; 27 | -------------------------------------------------------------------------------- /Mod/Modules/Modules/RenderUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class RenderUI : public Module { 5 | public: 6 | RenderUI(); 7 | public: 8 | virtual auto onEnable() -> void override; 9 | virtual auto onDisable() -> void override; 10 | virtual auto onKeyUpdate(int key, bool isDown)-> void override; 11 | virtual auto onImGUIRender()->void override; 12 | virtual auto onloadConfigFile(json& data)->void override; 13 | virtual auto onsaveConfigFile(json& data)->void override; 14 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/ShowCoordinates.cpp: -------------------------------------------------------------------------------- 1 | #include "ShowCoordinates.h" 2 | 3 | ShowCoordinates::ShowCoordinates() : Module(0, "ShowCoordinates", "开启后强制显示左上角坐标") { 4 | //setEnabled(true); 5 | } 6 | 7 | auto ShowCoordinates::onloadConfigFile(json& data)->void { 8 | setEnabled(config::readDataFromJson(data, "enable", true)); 9 | } 10 | auto ShowCoordinates::onsaveConfigFile(json& data)->void { 11 | data["enable"] = isEnabled(); 12 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/ShowCoordinates.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | 5 | class ShowCoordinates : public Module { 6 | public: 7 | ShowCoordinates(); 8 | 9 | public: 10 | virtual auto onloadConfigFile(json& data)->void override; 11 | virtual auto onsaveConfigFile(json& data)->void override; 12 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/TPPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "TPPoint.h" 2 | #include "../../Utils/Game.h" 3 | #include "LocalPlayer.h" 4 | #include "ClientInstance.h" 5 | 6 | #include "imgui.h" 7 | 8 | TPPoint::TPPoint() : Module(VK_F3, "TPPoint", "传送坐标点,由高到低当心摔落伤害") { 9 | SetKeyMode(KeyMode::Trigger); 10 | } 11 | 12 | auto TPPoint::onTrigger()->void { 13 | if (!Game::Cinstance) { 14 | return; 15 | } 16 | LocalPlayer* lp = Game::Cinstance->getCILocalPlayer(); 17 | if (!lp) { 18 | return; 19 | } 20 | //记录传送点 21 | if (Game::IsKeyDown(VK_CONTROL)) { 22 | point = *lp->getPosition(); 23 | return; 24 | } 25 | 26 | //读取并传送过去 27 | if (Game::IsKeyDown(VK_SHIFT) && point.has_value()) { 28 | //Game::localplayer->setPos(point); 29 | vec3_t tpPos = *point; 30 | lp->teleportTo(&tpPos,true,0,1); 31 | } 32 | } 33 | 34 | auto TPPoint::getBindKeyName()->std::string { 35 | //ret : CTRL + SHIFT + F 36 | std::string name = Utils::getKeybindName(VK_SHIFT); 37 | name += "/"; 38 | name += Utils::getKeybindName(VK_CONTROL); 39 | name += "+"; 40 | name += Module::getBindKeyName(); 41 | return name; 42 | } 43 | 44 | auto TPPoint::onInternalImGUIRender() -> void 45 | { 46 | if (point.has_value()) { 47 | ImGui::Text("快捷键传送点: x:%.3f, y:%.3f, z:%.3f", point->x, point->y, point->z); 48 | } 49 | else { 50 | ImGui::Text("未记录传送点"); 51 | } 52 | 53 | if (ImGui::Button("添加", { -1, 0 })) { 54 | ImGui::OpenPopup("AddTpPointMenu"); 55 | } 56 | ImGui::Separator(); 57 | 58 | if (ImGui::BeginPopup("AddTpPointMenu")) { 59 | static char name[30] = { '\0' }; 60 | ImGui::InputTextWithHint("传送点名称", "HOME", name, IM_ARRAYSIZE(name)); 61 | 62 | if (ImGui::Button("添加")) { 63 | auto lp = Game::Cinstance->getCILocalPlayer(); 64 | if (lp) { 65 | std::string tppointlistname = name; 66 | 67 | TpPointList pointlist{ tppointlistname, {0} , 0}; 68 | 69 | tpPoints.push_back(pointlist); 70 | 71 | ImGui::CloseCurrentPopup(); 72 | } 73 | } 74 | 75 | ImGui::EndPopup(); 76 | } 77 | 78 | for (auto i = tpPoints.begin(); i != tpPoints.end(); i++) { 79 | auto& list = (*i); 80 | //ImGui::Text(list.name.c_str()); 81 | ImGui::PushID(list.name.c_str()); 82 | { 83 | float* pos = list.point; 84 | ImGui::DragFloat3(list.name.c_str(), pos, 0.1f); 85 | { 86 | if (ImGui::Button("读取")) { 87 | if (!Game::Cinstance) { 88 | return; 89 | } 90 | LocalPlayer* lp = Game::Cinstance->getCILocalPlayer(); 91 | if (!lp) { 92 | return; 93 | } 94 | vec3_t lppos = *lp->getPosition(); 95 | pos[0] = lppos.x; 96 | pos[1] = lppos.y; 97 | pos[2] = lppos.z; 98 | } 99 | } 100 | ImGui::SameLine(); 101 | { 102 | if (ImGui::Button("传送")) { 103 | if (!Game::Cinstance) { 104 | return; 105 | } 106 | LocalPlayer* lp = Game::Cinstance->getCILocalPlayer(); 107 | if (!lp) { 108 | return; 109 | } 110 | vec3_t lppos(pos[0], pos[1], pos[2]); 111 | lp->teleportTo(&lppos, true, 0, 1); 112 | } 113 | } 114 | ImGui::SameLine(); 115 | { 116 | ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(0.f, 0.6f, 0.6f)); 117 | ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(0.f, 0.7f, 0.7f)); 118 | ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(0.f, 0.8f, 0.8f)); 119 | if (ImGui::Button("删除")) { 120 | i = tpPoints.erase(i); 121 | if (i == tpPoints.end()) 122 | { 123 | ImGui::PopStyleColor(3); 124 | ImGui::PopID(); 125 | break; 126 | } 127 | } 128 | ImGui::PopStyleColor(3); 129 | } 130 | ImGui::Separator(); 131 | } 132 | ImGui::PopID(); 133 | } 134 | } 135 | 136 | auto TPPoint::onloadConfigFile(json& data)->void { 137 | //setEnabled(config::readDataFromJson(data, "enable", true)); 138 | // 遍历 JSON 数组并输出每个元素 139 | if(!data["tppoints"].is_array()) 140 | data["tppoints"].array(); 141 | tpPoints.clear(); 142 | for (const auto& item : data["tppoints"]) { 143 | TpPointList list{}; 144 | list.name = item["name"].get(); 145 | list.point[0] = item["position"]["x"].get(); 146 | list.point[1] = item["position"]["y"].get(); 147 | list.point[2] = item["position"]["z"].get(); 148 | list.dim = item["dim"].get(); 149 | tpPoints.push_back(list); 150 | } 151 | 152 | } 153 | auto TPPoint::onsaveConfigFile(json& data)->void { 154 | //data["enable"] = isEnabled(); 155 | //data["tppoints"] 156 | data["tppoints"].clear(); 157 | for (auto pos : tpPoints) { 158 | json current_json; 159 | current_json["name"] = pos.name; 160 | current_json["position"]["x"] = pos.point[0]; 161 | current_json["position"]["y"] = pos.point[1]; 162 | current_json["position"]["z"] = pos.point[2]; 163 | current_json["dim"] = pos.dim; 164 | 165 | data["tppoints"].push_back(current_json); 166 | } 167 | } -------------------------------------------------------------------------------- /Mod/Modules/Modules/TPPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class TPPoint : public Module { 5 | struct TpPointList 6 | { 7 | std::string name; 8 | float point[3]; 9 | int dim; 10 | }; 11 | public: 12 | TPPoint(); 13 | 14 | private: 15 | std::optional point; 16 | std::vector tpPoints = {}; 17 | 18 | public: 19 | virtual auto onTrigger()->void override; 20 | virtual auto getBindKeyName()->std::string override; 21 | virtual auto onInternalImGUIRender()->void override; 22 | virtual auto onloadConfigFile(json& data)->void override; 23 | virtual auto onsaveConfigFile(json& data)->void override; 24 | }; -------------------------------------------------------------------------------- /Mod/Modules/Modules/Traverse.cpp: -------------------------------------------------------------------------------- 1 | #include "Traverse.h" 2 | #include "../../Utils/Game.h" 3 | #include "Actor.h" 4 | #include "LocalPlayer.h" 5 | #include "ClientInstance.h" 6 | 7 | Traverse::Traverse() : Module(VK_F2, "Traverse", "向所视方向前进一格") { 8 | //SetKeyMode(KeyMode::Trigger); 9 | //setEnabled(true); 10 | AddBoolUIValue("需要按下Ctrl键", &needCtrl); 11 | } 12 | 13 | 14 | int rotToCoordinateX(float X) { 15 | int ret = 0; 16 | if (X < 157.5f && X > 22.5f) { 17 | return -1; 18 | } 19 | if (X > -157.5f && X < -22.5f) { 20 | return 1; 21 | } 22 | return 0; 23 | } 24 | 25 | int rotToCoordinateZ(float X) { 26 | int ret = 0; 27 | if ((X < 180.f && X > 112.5f) || (X < -112.5f && X > -180.f)) { 28 | return -1; 29 | } 30 | if (X > -67.5f && X < 67.5f) { 31 | return 1; 32 | } 33 | return 0; 34 | } 35 | 36 | 37 | auto Traverse::getBindKeyName()->std::string { 38 | std::string name = "(MButton)"; 39 | name += Module::getBindKeyName(); 40 | return name; 41 | } 42 | 43 | auto Traverse::onMouseUpdate(char mousebutton, char isdown, __int16 mouseX, __int16 mouseY, __int16 relativeMovementX, __int16 relativeMovementY)->void { 44 | if (isEnabled()) { 45 | if (mousebutton == VK_CANCEL && isdown) { 46 | //LocalPlayer* lp = Game::localplayer; 47 | LocalPlayer* lp = Game::Cinstance->getCILocalPlayer(); 48 | if (lp == nullptr || !lp->isValid()) { 49 | return; 50 | } 51 | if (needCtrl) { 52 | if (!Game::IsKeyDown(VK_CONTROL)) { 53 | return; 54 | } 55 | } 56 | 57 | vec2_t rot = *lp->getRotEx1(); 58 | vec3_t pos = *lp->getPosition(); 59 | if (rot.x > 67.5f) { 60 | //如果玩家看向地面 则向下tp一格以穿过地面 61 | vec3_t toPos = vec3_t(pos.x, pos.y-1, pos.z); 62 | lp->setPos(&toPos); 63 | } 64 | else { 65 | vec3_t toPos = vec3_t(pos.x + (float)rotToCoordinateX(rot.y), pos.y, pos.z + (float)rotToCoordinateZ(rot.y)); 66 | //lp->setPos(vec3_t(pos.x + rotToCoordinateX(rot.y), pos.y, pos.z + rotToCoordinateZ(rot.y))); 67 | lp->setPos(&toPos); 68 | //lp->teleportTo(&toPos, true, 0, 1); 69 | } 70 | } 71 | } 72 | } 73 | 74 | auto Traverse::onloadConfigFile(json& data)->void { 75 | setEnabled(config::readDataFromJson(data, "enable", true)); 76 | needCtrl = config::readDataFromJson(data, "needCtrl", true); 77 | } 78 | auto Traverse::onsaveConfigFile(json& data)->void { 79 | data["enable"] = isEnabled(); 80 | data["needCtrl"] = needCtrl; 81 | } 82 | -------------------------------------------------------------------------------- /Mod/Modules/Modules/Traverse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Module.h" 3 | 4 | class Traverse : public Module { 5 | public: 6 | Traverse(); 7 | 8 | public: 9 | bool needCtrl = true; 10 | 11 | public: 12 | virtual auto getBindKeyName()->std::string override; 13 | virtual auto onMouseUpdate(char mousebutton, char isdown, __int16 mouseX, __int16 mouseY, __int16 relativeMovementX, __int16 relativeMovementY)->void override; 14 | virtual auto onloadConfigFile(json& data)->void override; 15 | virtual auto onsaveConfigFile(json& data)->void override; 16 | }; -------------------------------------------------------------------------------- /Mod/Render/Render.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imgui.h" 3 | #include "HMath.h" 4 | 5 | #include 6 | #include 7 | 8 | class Render { 9 | static vec2_t fov; 10 | static vec2_t screen; 11 | static vec3_t origin; 12 | static std::shared_ptr refdef; 13 | 14 | public: 15 | static void Updata(); 16 | 17 | static vec2_t getScreen(); 18 | 19 | /** 20 | * @brief 绘制方块Box 返回一个屏幕上的位置 21 | */ 22 | static std::optional RenderBlockBox(vec3_ti bPos,ImColor boxColor = ImColor(241, 196, 15, 255), float linesize = 1.5f); 23 | 24 | static std::optional RenderPlayerBox2D(class Player player, ImColor boxColor = ImColor(241, 196, 15, 255), float linesize = 1.5f); 25 | 26 | static std::optional RenderWorldBox2D(vec3_t pos, ImColor boxColor = ImColor(241, 196, 15, 255), float linesize = 1.5f); 27 | 28 | static std::optional RenderAABB2D(class AABB aabb, ImColor boxColor = ImColor(241, 196, 15, 255), float linesize = 1.5f); 29 | 30 | static std::optional RenderAABB(class AABB aabb, ImColor boxColor = ImColor(241, 196, 15, 255), float linesize = 1.5f); 31 | }; -------------------------------------------------------------------------------- /Mod/Utils/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class Game 6 | { 7 | public: 8 | static bool ModState; 9 | static class ServerPlayer* localServerPlayer; 10 | static class LocalPlayer* localplayer; 11 | static class BitmapFont* mcfont; 12 | static class ClientInstance* Cinstance; 13 | static void* WindowsHandle; 14 | static void* ChildWindowsHandle; 15 | static uintptr_t KeyMap; 16 | static bool MouseKeyDown[]; 17 | static std::string ImConfigIni; 18 | private: 19 | static class ModuleManager* modmag; 20 | public: 21 | static auto init()->void; 22 | static auto exit()->void; 23 | static auto GetModuleManager()->class ModuleManager*; 24 | 25 | public: 26 | static auto IsKeyDown(int key)->bool; 27 | static auto IsKeyPressed(int key)->bool; 28 | static auto IsMouseDown(int key) -> bool; 29 | 30 | static auto GetLocalServerPlayer() -> class ServerPlayer*; 31 | 32 | }; -------------------------------------------------------------------------------- /Mod/Utils/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "Logger.h" 2 | 3 | #ifndef WIN32_LEAN_AND_MEAN 4 | #define WIN32_LEAN_AND_MEAN 5 | #endif 6 | #include 7 | 8 | #include "Utils.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | using namespace ABI::Windows::Storage; 16 | using namespace Microsoft::WRL; 17 | using namespace Microsoft::WRL::Wrappers; 18 | 19 | char logPath[200]; 20 | bool initializedLogger = false; 21 | bool loggerActive = true; 22 | CRITICAL_SECTION loggerLock; 23 | std::mutex vecMutex; 24 | std::mutex injMutex; 25 | std::vector stringPrintVector = std::vector(); 26 | std::vector> stringSendToInjector; 27 | 28 | bool Logger::isActive() { 29 | return loggerActive && initializedLogger; 30 | } 31 | 32 | std::wstring Logger::GetRoamingFolderPath() { 33 | return Utils::GetRoamingFolderPath(); 34 | } 35 | 36 | void Logger::WriteLogFileF(const char* fmt, ...) { 37 | if (!loggerActive) 38 | return; 39 | FILE* pFile; 40 | 41 | if (!initializedLogger) { 42 | initializedLogger = true; 43 | InitializeCriticalSection(&loggerLock); 44 | EnterCriticalSection(&loggerLock); 45 | std::wstring roam = GetRoamingFolderPath(); 46 | roam += L"\\Mod"; 47 | sprintf_s(logPath, 200, "%S\\logs.txt", roam.c_str()); 48 | 49 | try { 50 | remove(logPath); 51 | } catch (std::exception e) { 52 | } 53 | 54 | } else 55 | EnterCriticalSection(&loggerLock); 56 | 57 | pFile = _fsopen(logPath, "a", _SH_DENYNO); // Open File with DENY_WRITE so other programs can only read stuff from log 58 | if (pFile != nullptr) { 59 | std::stringstream ssTime; 60 | Utils::ApplySystemTime(&ssTime); 61 | 62 | char logMessage[500]; 63 | char timeStamp[20]; 64 | sprintf_s(timeStamp, 20, "%s", ssTime.str().c_str()); 65 | 66 | va_list arg; 67 | va_start(arg, fmt); 68 | int numCharacters = vsprintf_s(logMessage, 300, const_cast(fmt), arg); 69 | va_end(arg); 70 | fprintf(pFile, "%s%s", timeStamp, Utils::ANSItoUTF8(logMessage).c_str()); 71 | fprintf(pFile, "\n"); 72 | 73 | fclose(pFile); 74 | 75 | if (numCharacters < 100) { 76 | TextForPrint textForPrint{}; 77 | strcpy_s(textForPrint.text, 100, logMessage); 78 | strcpy_s(textForPrint.time, 20, timeStamp); 79 | auto lock = Logger::GetTextToPrintLock(); 80 | stringPrintVector.push_back(textForPrint); 81 | } 82 | } 83 | LeaveCriticalSection(&loggerLock); 84 | } 85 | 86 | void Logger::WriteBigLogFileF(size_t maxSize, const char* fmt, ...) { 87 | if (!loggerActive) 88 | return; 89 | FILE* pFile; 90 | 91 | if (!initializedLogger) { 92 | initializedLogger = true; 93 | InitializeCriticalSection(&loggerLock); 94 | EnterCriticalSection(&loggerLock); 95 | 96 | #ifdef _DEBUG 97 | std::string s("C:\\Users\\CNGEGE\\Desktop"); 98 | std::wstring roam(s.begin(), s.end()); 99 | #else 100 | std::wstring roam = GetRoamingFolderPath(); 101 | #endif 102 | sprintf_s(logPath, 200, "%S\\logs.txt", roam.c_str()); 103 | 104 | try { 105 | remove(logPath); 106 | } catch (std::exception e) { 107 | } 108 | 109 | } else 110 | EnterCriticalSection(&loggerLock); 111 | 112 | pFile = _fsopen(logPath, "a", _SH_DENYWR); // Open File with DENY_WRITE so other programs can only read stuff from log 113 | if (pFile != nullptr) { 114 | std::stringstream ssTime; 115 | Utils::ApplySystemTime(&ssTime); 116 | 117 | char* logMessage = new char[maxSize + 1]; 118 | char timeStamp[20]; 119 | sprintf_s(timeStamp, 20, "%s", ssTime.str().c_str()); 120 | 121 | va_list arg; 122 | va_start(arg, fmt); 123 | int numCharacters = vsprintf_s(logMessage, maxSize + 1, fmt, arg); 124 | va_end(arg); 125 | fprintf(pFile, "%s%s", timeStamp, Utils::ANSItoUTF8(logMessage).c_str()); 126 | fprintf(pFile, "\n"); 127 | 128 | fclose(pFile); 129 | 130 | if (numCharacters < 100) { 131 | TextForPrint textForPrint{}; 132 | strcpy_s(textForPrint.text, 100, logMessage); 133 | strcpy_s(textForPrint.time, 20, timeStamp); 134 | auto lock = Logger::GetTextToPrintLock(); 135 | stringPrintVector.push_back(textForPrint); 136 | } 137 | if (numCharacters < 2900) { 138 | auto textForPrint = std::make_shared(); 139 | strcpy_s(textForPrint->text, 2900, logMessage); 140 | strcpy_s(textForPrint->time, 20, timeStamp); 141 | auto lock = Logger::GetTextToInjectorLock(); 142 | stringSendToInjector.push_back(textForPrint); 143 | } 144 | delete[] logMessage; 145 | } 146 | LeaveCriticalSection(&loggerLock); 147 | } 148 | 149 | std::vector* Logger::GetTextToPrint() { 150 | return &stringPrintVector; 151 | } 152 | 153 | std::vector>* Logger::GetTextToSend() { 154 | return &stringSendToInjector; 155 | } 156 | 157 | std::lock_guard Logger::GetTextToPrintLock() { 158 | return std::lock_guard(vecMutex); 159 | } 160 | 161 | std::lock_guard Logger::GetTextToInjectorLock() { 162 | return std::lock_guard(injMutex); 163 | } 164 | 165 | void Logger::Disable() { 166 | loggerActive = false; 167 | #ifdef _DEBUG 168 | EnterCriticalSection(&loggerLock); 169 | auto lock = Logger::GetTextToPrintLock(); 170 | LeaveCriticalSection(&loggerLock); 171 | Sleep(50); 172 | 173 | DeleteCriticalSection(&loggerLock); 174 | #endif 175 | } 176 | void Logger::SendToConsoleF(const char* msg) { 177 | if (!loggerActive) 178 | return; 179 | 180 | if (!initializedLogger) 181 | return; 182 | 183 | std::stringstream ssTime; 184 | Utils::ApplySystemTime(&ssTime); 185 | 186 | char timeStamp[20]; 187 | sprintf_s(timeStamp, 20, "%s", ssTime.str().c_str()); 188 | auto numCharacters = strnlen_s(msg, 300); 189 | 190 | if (numCharacters < 300) { 191 | auto textForPrint = std::make_shared(); 192 | strcpy_s(textForPrint->text, 2900, msg); 193 | strcpy_s(textForPrint->time, 20, timeStamp); 194 | auto lock = Logger::GetTextToInjectorLock(); 195 | stringSendToInjector.push_back(textForPrint); 196 | } 197 | 198 | } 199 | -------------------------------------------------------------------------------- /Mod/Utils/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef _DEBUG 8 | #include 9 | #include 10 | #include 11 | #endif 12 | 13 | #include "xorstr.h" 14 | #include 15 | 16 | #pragma comment(lib, "runtimeobject") 17 | 18 | #ifndef logF 19 | //#define logF(x) Logger::WriteLogFileF(XorString(x)) 20 | #define logF(x, ...) Logger::WriteLogFileF(x, __VA_ARGS__) 21 | //#define logF(x, ...) Logger::WriteLogFileF(XorString(x), __VA_ARGS__) 22 | #endif 23 | 24 | #ifndef logF_Debug 25 | #ifdef _DEBUG 26 | #define logF_Debug(x, ...) Logger::WriteLogFileF(x, __VA_ARGS__) 27 | #else 28 | #define logF_Debug(x, ...) 29 | #endif 30 | #endif 31 | 32 | #ifndef logBF 33 | //#define logF(x) Logger::WriteLogFileF(XorString(x)) 34 | #define logBF(x, ...) Logger::WriteBigLogFileF(2000, x, __VA_ARGS__) 35 | //#define logF(x, ...) Logger::WriteLogFileF(XorString(x), __VA_ARGS__) 36 | #endif 37 | 38 | #ifndef logBF_Debug 39 | #ifdef _DEBUG 40 | #define logBF_Debug(x, ...) Logger::WriteBigLogFileF(2000, x, __VA_ARGS__) 41 | #else 42 | #define logBF_Debug(x, ...) 43 | #endif 44 | #endif 45 | 46 | struct TextForPrint { 47 | char time[20]; 48 | char text[100]; 49 | }; 50 | 51 | struct TextForPrintBig { 52 | char time[20]; 53 | char text[2900]; 54 | }; 55 | 56 | class Logger { 57 | 58 | public: 59 | static bool isActive(); 60 | static std::wstring GetRoamingFolderPath(); 61 | static void WriteLogFileF(const char* fmt, ...); 62 | static void WriteBigLogFileF(size_t maxSize, const char* fmt, ...); 63 | static void SendToConsoleF(const char* msg); 64 | static std::vector* GetTextToPrint(); 65 | static std::vector>* GetTextToSend(); 66 | static std::lock_guard GetTextToPrintLock(); 67 | static std::lock_guard GetTextToInjectorLock(); 68 | //static std::vector stringPrintVector; 69 | static void Disable(); 70 | }; 71 | -------------------------------------------------------------------------------- /Mod/Utils/config.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include 3 | #include "Utils.h" 4 | //#include "Logger.h" 5 | //#include 6 | //#include 7 | //#include 8 | 9 | std::string config::currentSaveConfigFile = "Default"; // 指示当前使用的配置文件的默认值 也就是默认使用 Default.json 这个配置文件 10 | 11 | std::string config::getConfigFilePath() { 12 | static std::string configFilePath = Utils::WStringToString(Utils::GetRoamingFolderPath()) + "\\Mod\\Config\\"; 13 | return configFilePath; 14 | } 15 | 16 | 17 | std::vector config::findAllConfigFile() { 18 | std::vector files; 19 | intptr_t hFile = 0; 20 | struct _finddata_t fileinfo; 21 | if ((hFile = _findfirst(getConfigFilePath().append("*.json").c_str(),&fileinfo)) != -1) { 22 | do { 23 | if (!(fileinfo.attrib & _A_SUBDIR)) { 24 | if (strcmp(fileinfo.name, "config.json") != 0) { // config.json 作为固定配置,和其他保存模块信息等配置不一样 25 | auto fname = std::string(fileinfo.name); 26 | auto find = fname.find(".json"); 27 | auto findedname = fname.substr(0, find); 28 | files.push_back(Utils::utf8_check_is_valid(findedname) ? findedname : Utils::ANSItoUTF8(findedname.c_str())); 29 | } 30 | } 31 | else { 32 | //递归查询内部文件夹 这里不需要 33 | } 34 | } while (_findnext(hFile, &fileinfo) == 0); 35 | } 36 | _findclose(hFile); 37 | return files; 38 | } 39 | 40 | 41 | 42 | json config::loadConfigonRootFromFile(const std::string& name) { 43 | json ret = {}; 44 | std::ifstream f((getConfigFilePath() + (Utils::utf8_check_is_valid(name) ? Utils::UTF8toANSI(name.c_str()) : name) + ".json").c_str()); 45 | if (f.good()) //表示配置文件存在 46 | { 47 | f >> ret; 48 | f.close(); 49 | } 50 | return ret; 51 | } 52 | 53 | json config::loadConfigonRootFromDefaultFile() { 54 | return loadConfigonRootFromFile("Default"); 55 | } 56 | 57 | json config::loadConfigFromFile(const std::string& name, std::string key) { 58 | auto root = loadConfigonRootFromFile(name); 59 | if (root.contains(key)) { 60 | return root[key]; 61 | } 62 | else { 63 | return {}; 64 | } 65 | } 66 | 67 | json config::loadConfigFromDefaultFile(std::string key) { 68 | return loadConfigFromFile("Default", key); 69 | } 70 | 71 | // 写入配置 72 | bool config::writeConfigonRootToFile(const std::string& name, json data) { 73 | std::ofstream c((getConfigFilePath() + (Utils::utf8_check_is_valid(name) ? Utils::UTF8toANSI(name.c_str()) : name) + ".json").c_str()); 74 | c << data.dump(2); 75 | c.close(); 76 | return true; 77 | } 78 | 79 | bool config::writeConfigonRootFromDefaultFile(json data) { 80 | return writeConfigonRootToFile("Default", data); 81 | } 82 | 83 | bool config::removeConfigFile(std::string confignName) { 84 | std::string targetFile = getConfigFilePath() + (Utils::utf8_check_is_valid(confignName) ? Utils::UTF8toANSI(confignName.c_str()) : confignName) + ".json"; 85 | if (!std::filesystem::exists(targetFile)) { 86 | return true; 87 | } 88 | int out = std::remove(targetFile.c_str()); 89 | if (out == 0) { 90 | return true; 91 | } 92 | else { 93 | return false; 94 | } 95 | } -------------------------------------------------------------------------------- /Mod/Utils/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Json.hpp" 4 | 5 | using namespace nlohmann; 6 | 7 | class config { 8 | public: 9 | static std::string currentSaveConfigFile; 10 | public: 11 | //static bool setconfigFile(const std::string& name); // 无需后缀 统一后缀.json 12 | static std::string getConfigFilePath(); // 获取配置文件的目录位置 \\结尾 13 | static std::vector findAllConfigFile(); // 从配置文件目录中 读取所有后缀为json的文件 14 | static json loadConfigonRootFromFile(const std::string& name); // 读取某个配置文件中的json,返回整个json内容 15 | static json loadConfigonRootFromDefaultFile(); // 读取默认配置文件中的json,返回整个json内容 16 | static json loadConfigFromFile(const std::string& name, std::string key); // 读取某个配置文件中的json,返回指定key的json内容 17 | static json loadConfigFromDefaultFile(std::string key); // 读取默认配置文件中的json,返回指定key的json内容(默认配置文件:Default.json) 18 | 19 | static bool writeConfigonRootToFile(const std::string& name, json data); // 将json写入到整个配置中 20 | static bool writeConfigonRootFromDefaultFile(json data); // 将json完全写到默认配置文件中 21 | static bool removeConfigFile(std::string configName); // 删除配置文件 22 | 23 | template 24 | static T readDataFromJson(json data, std::string key, T defdata); 25 | }; 26 | 27 | template 28 | T config::readDataFromJson(json data, std::string key, T defdata) { 29 | if (data.contains(key)) { 30 | return data[key]; 31 | } 32 | else { 33 | return defdata; 34 | } 35 | } -------------------------------------------------------------------------------- /Mod/Utils/http.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // 3 | // *一个简单的针对UWP程序的 http/https 请求实现 4 | // *CNGEGE 5 | // *by https://learn.microsoft.com/en-us/windows/uwp/networking/httpclient?source=recommendations 6 | // 7 | 8 | //#include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace concurrency; 19 | class NetClient { 20 | public: 21 | int StatusCode = 200; 22 | winrt::Windows::Web::Http::HttpClient httpClient; 23 | winrt::Windows::Web::Http::HttpResponseMessage httpResponseMessage; 24 | 25 | public: 26 | bool StatusSuccess() { 27 | if (httpResponseMessage) { 28 | return httpResponseMessage.IsSuccessStatusCode(); 29 | }else { 30 | return false; 31 | } 32 | } 33 | 34 | std::string GetAsyncAsString() { 35 | try { 36 | httpResponseMessage.EnsureSuccessStatusCode(); 37 | auto ret = winrt::to_string(httpResponseMessage.Content().ReadAsStringAsync().get()); 38 | httpClient.Close(); 39 | return ret; 40 | } 41 | catch (...) { 42 | return {}; 43 | } 44 | } 45 | 46 | winrt::Windows::Storage::Streams::IBuffer GetAsyncAsBuffer() { 47 | try { 48 | httpResponseMessage.EnsureSuccessStatusCode(); 49 | auto readAsBufferAsync = httpResponseMessage.Content().ReadAsBufferAsync(); 50 | //create_task(readAsBufferAsync).wait(); 51 | auto m_response = readAsBufferAsync.GetResults(); 52 | //create_task(m_response).wait(); 53 | httpClient.Close(); 54 | return m_response; 55 | } 56 | catch (...) { 57 | return {}; 58 | } 59 | } 60 | 61 | /// 62 | /// 将IBuffer流写入文件 63 | /// 64 | /// 必须要在 [Microsoft.MinecraftUWP_8wekyb3d8bbwe] 文件夹下的绝对路径,否则崩溃 65 | /// IBuffer流 66 | /// 是否写入成功 67 | static bool WriteFile(std::string file, winrt::Windows::Storage::Streams::IBuffer& buff) { 68 | if (!buff) { 69 | return false; 70 | } 71 | try { 72 | std::replace(file.begin(), file.end(), '/', '\\'); 73 | auto wstr = winrt::to_hstring(file); 74 | if (_access(file.c_str(),0)) { 75 | std::ofstream(file).close(); 76 | } 77 | winrt::Windows::Storage::StorageFile sfile = winrt::Windows::Storage::StorageFile::GetFileFromPathAsync(wstr).get(); 78 | winrt::Windows::Storage::FileIO::WriteBufferAsync(sfile, buff); 79 | return true; 80 | } 81 | catch (...) { 82 | return false; 83 | } 84 | } 85 | 86 | public: 87 | static NetClient GetAsync(std::string url) { 88 | NetClient network; 89 | winrt::Windows::Foundation::Uri requestUri{ winrt::to_hstring(url) }; 90 | network.httpResponseMessage = network.httpClient.GetAsync(requestUri).get(); 91 | network.StatusCode = (uint32_t)network.httpResponseMessage.StatusCode(); 92 | return network; 93 | } 94 | 95 | static NetClient PostAsync(std::string url,std::string json = "{}") { 96 | NetClient network; 97 | winrt::Windows::Foundation::Uri requestUri{ winrt::to_hstring(url) }; 98 | winrt::Windows::Web::Http::HttpStringContent jsonContent( 99 | //L"{ \"firstName\": \"Eliot\" }", 100 | winrt::to_hstring(json), 101 | winrt::Windows::Storage::Streams::UnicodeEncoding::Utf8, 102 | L"application/json"); 103 | network.httpResponseMessage = network.httpClient.PostAsync(requestUri, jsonContent).get(); 104 | network.StatusCode = (uint32_t)network.httpResponseMessage.StatusCode(); 105 | return network; 106 | } 107 | }; 108 | -------------------------------------------------------------------------------- /Mod/Utils/xorstr.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////// 2 | template 3 | struct EnsureCompileTime { 4 | enum : int { 5 | Value = X 6 | }; 7 | }; 8 | //////////////////////////////////////////////////////////////////// 9 | 10 | //////////////////////////////////////////////////////////////////// 11 | //Use Compile-Time as seed 12 | #define XorSeed ((__TIME__[7] - '0') * 1 + (__TIME__[6] - '0') * 10 + \ 13 | (__TIME__[4] - '0') * 60 + (__TIME__[3] - '0') * 600 + \ 14 | (__TIME__[1] - '0') * 3600 + (__TIME__[0] - '0') * 36000) 15 | //////////////////////////////////////////////////////////////////// 16 | 17 | //////////////////////////////////////////////////////////////////// 18 | constexpr int LinearCongruentGenerator(int Rounds) { 19 | return 1013904223 + 1664525 * ((Rounds > 0) ? LinearCongruentGenerator(Rounds - 1) : XorSeed & 0xFFFFFFFF); 20 | } 21 | #define Random() EnsureCompileTime::Value //10 Rounds 22 | #define RandomNumber(Min, Max) (Min + (Random() % (Max - Min + 1))) 23 | //////////////////////////////////////////////////////////////////// 24 | 25 | //////////////////////////////////////////////////////////////////// 26 | template 27 | struct IndexList {}; 28 | //////////////////////////////////////////////////////////////////// 29 | 30 | //////////////////////////////////////////////////////////////////// 31 | template 32 | struct Append; 33 | template 34 | struct Append, Right> { 35 | typedef IndexList Result; 36 | }; 37 | //////////////////////////////////////////////////////////////////// 38 | 39 | //////////////////////////////////////////////////////////////////// 40 | template 41 | struct ConstructIndexList { 42 | typedef typename Append::Result, N - 1>::Result Result; 43 | }; 44 | template <> 45 | struct ConstructIndexList<0> { 46 | typedef IndexList<> Result; 47 | }; 48 | //////////////////////////////////////////////////////////////////// 49 | 50 | //////////////////////////////////////////////////////////////////// 51 | const char XORKEY = static_cast(RandomNumber(0, 0xFF)); 52 | __forceinline constexpr char EncryptCharacter(const char Character, int Index) { 53 | return Character ^ (XORKEY + Index); 54 | } 55 | 56 | template 57 | class CXorString; 58 | template 59 | class CXorString > { 60 | private: 61 | volatile char Value[sizeof...(Index) + 1]; 62 | 63 | public: 64 | __forceinline constexpr CXorString(const char* const String) 65 | : Value{EncryptCharacter(String[Index], Index)...} {} 66 | 67 | __forceinline volatile char* decrypt() { 68 | for (int t = 0; t < sizeof...(Index); t++) { 69 | Value[t] = Value[t] ^ (XORKEY + t); 70 | } 71 | Value[sizeof...(Index)] = '\0'; 72 | return Value; 73 | } 74 | 75 | __forceinline char* get() { 76 | return Value; 77 | } 78 | }; 79 | #define XorS(X, String) CXorString::Result> X(String) 80 | #define XorString(String) (CXorString::Result>(String).decrypt()) 81 | //#define XorString(String) String -------------------------------------------------------------------------------- /Mod/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : 定义 DLL 应用程序的入口点。 2 | #include "framework.h" 3 | #include "Loader.h" 4 | 5 | #ifdef _DEBUG 6 | #pragma comment(lib, "libMinHook.x64-v143-mdd.lib") 7 | #elif NDEBUG 8 | #pragma comment(lib, "libMinHook.x64-v143-md.lib") 9 | #endif 10 | 11 | #pragma comment(lib, "d2d1.lib") 12 | #pragma comment(lib, "d3d12.lib") 13 | #pragma comment(lib, "dwrite.lib") 14 | #pragma comment(lib, "version") 15 | 16 | //临时消除出现在Json.hpp 4281行的警告 17 | //#pragma warning(disable:26800) 18 | 19 | BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 20 | { 21 | switch (ul_reason_for_call) 22 | { 23 | case DLL_PROCESS_ATTACH: 24 | { 25 | CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Loader::init, hModule, NULL, NULL); 26 | DisableThreadLibraryCalls(hModule); //应用程序及其DLL的线程创建与销毁不再对此DLL进行通知 27 | break; 28 | } 29 | case DLL_PROCESS_DETACH: 30 | if (!Loader::Eject_Signal) { 31 | // 表示是外部卸载这个库 32 | Loader::RemoteFreeLib = true; 33 | Loader::Eject_Signal = true; 34 | Sleep(600); 35 | Loader::exit(hModule); 36 | } 37 | else { 38 | Loader::exit(hModule); // 这个有锁 多次调用没有关系 39 | } 40 | break; 41 | } 42 | return TRUE; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Mod/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 4 | // Windows 头文件 5 | #include 6 | -------------------------------------------------------------------------------- /Mod/imgui/imgui/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX11 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // Learn about Dear ImGui: 11 | // - FAQ https://dearimgui.com/faq 12 | // - Getting Started https://dearimgui.com/getting-started 13 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 14 | // - Introduction, links and more at the top of imgui.cpp 15 | 16 | #pragma once 17 | #include "imgui.h" // IMGUI_IMPL_API 18 | #ifndef IMGUI_DISABLE 19 | 20 | struct ID3D11Device; 21 | struct ID3D11DeviceContext; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 24 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 25 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 26 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 27 | 28 | // Use if you want to reset your rendering device without losing Dear ImGui state. 29 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 30 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); 31 | 32 | #endif // #ifndef IMGUI_DISABLE 33 | -------------------------------------------------------------------------------- /Mod/imgui/imgui/imgui_impl_dx12.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX12 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices. 7 | 8 | // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. 9 | // See imgui_impl_dx12.cpp file for details. 10 | 11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 13 | // Learn about Dear ImGui: 14 | // - FAQ https://dearimgui.com/faq 15 | // - Getting Started https://dearimgui.com/getting-started 16 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 17 | // - Introduction, links and more at the top of imgui.cpp 18 | 19 | #pragma once 20 | #include "imgui.h" // IMGUI_IMPL_API 21 | #ifndef IMGUI_DISABLE 22 | #include // DXGI_FORMAT 23 | 24 | struct ID3D12Device; 25 | struct ID3D12DescriptorHeap; 26 | struct ID3D12GraphicsCommandList; 27 | struct D3D12_CPU_DESCRIPTOR_HANDLE; 28 | struct D3D12_GPU_DESCRIPTOR_HANDLE; 29 | 30 | // cmd_list is the command list that the implementation will use to render imgui draw lists. 31 | // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate 32 | // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. 33 | // font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture. 34 | IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, 35 | D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); 36 | IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); 37 | IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); 38 | IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); 39 | 40 | // Use if you want to reset your rendering device without losing Dear ImGui state. 41 | IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); 42 | IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); 43 | 44 | #endif // #ifndef IMGUI_DISABLE 45 | -------------------------------------------------------------------------------- /Mod/imgui/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32-bits AND 64-bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen. 7 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set] 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 10 | 11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 13 | // Learn about Dear ImGui: 14 | // - FAQ https://dearimgui.com/faq 15 | // - Getting Started https://dearimgui.com/getting-started 16 | // - Documentation https://dearimgui.com/docs (same as your local docs/ folder). 17 | // - Introduction, links and more at the top of imgui.cpp 18 | 19 | #pragma once 20 | #include "imgui.h" // IMGUI_IMPL_API 21 | #ifndef IMGUI_DISABLE 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 24 | IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd); 25 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 27 | 28 | // Win32 message handler your application need to call. 29 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 30 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 31 | // - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE. 32 | 33 | #if 0 34 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 35 | #endif 36 | 37 | // DPI-related helpers (optional) 38 | // - Use to enable DPI awareness without having to create an application manifest. 39 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 40 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 41 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 42 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 43 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 44 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 45 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 46 | 47 | // Transparency related helpers (optional) [experimental] 48 | // - Use to enable alpha compositing transparency with the desktop. 49 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 50 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 51 | 52 | #endif // #ifndef IMGUI_DISABLE 53 | -------------------------------------------------------------------------------- /Mod/imgui/imgui_uwp_wndProc.cpp: -------------------------------------------------------------------------------- 1 | #include "imgui_uwp_wndProc.h" 2 | 3 | #include 4 | #include // GET_X_LPARAM(), GET_Y_LPARAM() 5 | 6 | #include "Logger.h" 7 | 8 | ImGuiMouseSource GetMouseSourceFromMessageExtraInfo() 9 | { 10 | LPARAM extra_info = ::GetMessageExtraInfo(); 11 | if ((extra_info & 0xFFFFFF80) == 0xFF515700) 12 | return ImGuiMouseSource_Pen; 13 | if ((extra_info & 0xFFFFFF80) == 0xFF515780) 14 | return ImGuiMouseSource_TouchScreen; 15 | return ImGuiMouseSource_Mouse; 16 | } 17 | 18 | void ImGui_ImplUWP_AddKeyEvent(ImGuiKey key, bool down, int native_keycode, int native_scancode = -1) 19 | { 20 | ImGuiIO& io = ImGui::GetIO(); 21 | io.AddKeyEvent(key, down); 22 | io.SetKeyEventNativeData(key, native_keycode, native_scancode); // To support legacy indexing (<1.87 user code) 23 | IM_UNUSED(native_scancode); 24 | } 25 | 26 | IMGUI_IMPL_API LRESULT ImGui_UWP_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 27 | 28 | #ifdef IMGUIINPUT_USE_WNDPROC 29 | 30 | //logF_Debug("msg: %02x", msg); 31 | //if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) { 32 | // return 1; 33 | //} 34 | 35 | switch (msg) 36 | { 37 | case DM_POINTERHITTEST: 38 | break; 39 | case WM_NCPOINTERDOWN: // 鼠标按下? 40 | case WM_POINTERDOWN: 41 | break; 42 | case WM_NCPOINTERUP: 43 | case WM_POINTERUP: 44 | break; 45 | case WM_NCPOINTERUPDATE: 46 | case WM_POINTERUPDATE: //ok 47 | break; 48 | case WM_PARENTNOTIFY: // 创建销毁子窗口时的消息 49 | break; 50 | case WM_POINTERACTIVATE: // 忽略 51 | break; 52 | case WM_POINTERCAPTURECHANGED: // 可能是鼠标移开游戏窗口 53 | break; 54 | case WM_POINTERDEVICECHANGE: // 忽略 当显示模式缩放时? 55 | case WM_POINTERDEVICEINRANGE: 56 | case WM_POINTERDEVICEOUTOFRANGE: 57 | break; 58 | case WM_POINTERENTER: // 鼠标悬停或移动 59 | break; 60 | case WM_POINTERLEAVE: // 移出窗口 ok 61 | break; 62 | case WM_POINTERROUTEDAWAY: // 什么路由到下一进程 63 | case WM_POINTERROUTEDRELEASED: // 和跨进程相关 64 | case WM_POINTERROUTEDTO: 65 | break; 66 | case WM_POINTERWHEEL: // 鼠标滚轮 67 | break; 68 | case WM_POINTERHWHEEL: // 横向滚轮 69 | break; 70 | case WM_TOUCHHITTESTING: 71 | break; 72 | // 以下是非官方链接中给出的消息 73 | case WM_MOUSEMOVE: //0x200 74 | break; 75 | 76 | case WM_SETCURSOR: //0x20 77 | case WM_MOUSEACTIVATE://0x21 78 | case WM_NCHITTEST: //0x84 命中测试 79 | case WM_IME_SETCONTEXT://0x281 80 | case WM_IME_NOTIFY://0x282 81 | case WM_SETFOCUS://0x7 82 | case WM_KILLFOCUS://0x8 83 | case WM_INPUT://0xFF 84 | case WM_SYSKEYDOWN://0x104 85 | case WM_SYSKEYUP://0x105 直接按下F10之类的健 86 | case WM_SYSCHAR://0x106 ALT+字符健 87 | case WM_SYSCOMMAND://0x112 88 | 89 | break; 90 | case 0xC07D://可能是指切换窗口 91 | case 0xC1D0: 92 | case 0x349: 93 | break; 94 | default: 95 | logF_Debug("defaultmsg: %02x", msg); 96 | break; 97 | } 98 | #endif // IMGUIINPUT_USE_WNDPROC 99 | 100 | switch (msg) 101 | { 102 | case WM_SETFOCUS://0x7 103 | case WM_KILLFOCUS://0x8 104 | { 105 | ImGuiIO& io = ImGui::GetIO(); 106 | //io.AddFocusEvent(msg == WM_SETFOCUS); 107 | } 108 | default: 109 | break; 110 | } 111 | 112 | return 0; 113 | } -------------------------------------------------------------------------------- /Mod/imgui/imgui_uwp_wndProc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "imgui.h" 4 | 5 | ImGuiMouseSource GetMouseSourceFromMessageExtraInfo(); 6 | 7 | void ImGui_ImplUWP_AddKeyEvent(ImGuiKey key, bool down, int native_keycode, int native_scancode); -------------------------------------------------------------------------------- /Mod/imgui/kiero/kiero.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDES_KIERO_KIERO 2 | #define INCLUDES_KIERO_KIERO 3 | 4 | #include 5 | 6 | #define KIERO_VERSION "1.2.12" 7 | 8 | #define KIERO_INCLUDE_D3D9 0 // 1 if you need D3D9 hook 9 | #define KIERO_INCLUDE_D3D10 0 // 1 if you need D3D10 hook 10 | #define KIERO_INCLUDE_D3D11 0 // 1 if you need D3D11 hook 11 | #define KIERO_INCLUDE_D3D12 1 // 1 if you need D3D12 hook 12 | #define KIERO_INCLUDE_OPENGL 0 // 1 if you need OpenGL hook 13 | #define KIERO_INCLUDE_VULKAN 0 // 1 if you need Vulkan hook 14 | #define KIERO_USE_MINHOOK 0 // 1 if you will use kiero::bind function 15 | 16 | #define KIERO_ARCH_X64 0 17 | #define KIERO_ARCH_X86 0 18 | 19 | #if defined(_M_X64) 20 | #undef KIERO_ARCH_X64 21 | #define KIERO_ARCH_X64 1 22 | #else 23 | #undef KIERO_ARCH_X86 24 | #define KIERO_ARCH_X86 1 25 | #endif 26 | 27 | #if KIERO_ARCH_X64 28 | typedef uint64_t uint150_t; 29 | #else 30 | typedef uint32_t uint150_t; 31 | #endif 32 | 33 | namespace kiero { 34 | struct Status { 35 | enum Enum { 36 | UnknownError = -1, 37 | NotSupportedError = -2, 38 | ModuleNotFoundError = -3, 39 | 40 | AlreadyInitializedError = -4, 41 | NotInitializedError = -5, 42 | 43 | Success = 0, 44 | }; 45 | }; 46 | 47 | struct RenderType { 48 | enum Enum { 49 | None, 50 | 51 | D3D9, 52 | D3D10, 53 | D3D11, 54 | D3D12, 55 | 56 | OpenGL, 57 | Vulkan, 58 | 59 | Auto 60 | }; 61 | }; 62 | 63 | Status::Enum init(RenderType::Enum renderType); 64 | void shutdown(); 65 | 66 | Status::Enum bind(uint16_t index, void** original, void* function); 67 | void unbind(uint16_t index); 68 | 69 | RenderType::Enum getRenderType(); 70 | uint150_t* getMethodsTable(); 71 | } // namespace kiero 72 | 73 | #endif /* INCLUDES_KIERO_KIERO */ -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_offset_rect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma warning(disable:26495) 3 | 4 | #include "imgui.h" 5 | 6 | // Helper: ImOffsetRect A set of offsets to apply to an ImRect. 7 | struct IMGUI_API ImOffsetRect 8 | { 9 | union 10 | { 11 | float Offsets[4]; 12 | 13 | struct 14 | { 15 | float Top; 16 | float Left; 17 | float Bottom; 18 | float Right; 19 | }; 20 | }; 21 | 22 | constexpr ImOffsetRect() : Top(0.0f), Left(0.0f), Bottom(0.0f), Right(0.0f) {} 23 | constexpr ImOffsetRect(const ImVec2& topLeft, const ImVec2& bottomRight) : ImOffsetRect(topLeft.y, topLeft.x, bottomRight.y, bottomRight.x) {} 24 | constexpr ImOffsetRect(const ImVec4& v) : ImOffsetRect(v.x, v.y, v.z, v.w) {} 25 | constexpr ImOffsetRect(float top, float left, float bottom, float right) : Top(top), Left(left), Bottom(bottom), Right(right) {} 26 | constexpr ImOffsetRect(float all) : Top(all), Left(all), Bottom(all), Right(all) {} 27 | 28 | ImVec2 GetSize() const { return ImVec2(Left + Right, Top + Bottom); } 29 | float GetWidth() const { return Left + Right; } 30 | float GetHeight() const { return Top + Bottom; } 31 | float GetAverage() const { return (Top + Left + Bottom + Right) / 4.0f; } 32 | ImOffsetRect MirrorHorizontally() const { return ImOffsetRect(Top, Right, Bottom, Left); } 33 | ImOffsetRect MirrorVertically() const { return ImOffsetRect(Bottom, Left, Top, Right); } 34 | ImOffsetRect Mirror() const { return ImOffsetRect(Bottom, Right, Top, Left); } 35 | }; 36 | 37 | // Helpers: ImOffsetRect operators 38 | IM_MSVC_RUNTIME_CHECKS_OFF 39 | static inline ImOffsetRect operator+(const ImOffsetRect& lhs, const ImOffsetRect& rhs) { return ImOffsetRect(lhs.Top + rhs.Top, lhs.Left + rhs.Left, lhs.Bottom + rhs.Bottom, lhs.Right + rhs.Right); } 40 | static inline ImOffsetRect operator-(const ImOffsetRect& lhs, const ImOffsetRect& rhs) { return ImOffsetRect(lhs.Top - rhs.Top, lhs.Left - rhs.Left, lhs.Bottom - rhs.Bottom, lhs.Right - rhs.Right); } 41 | static inline ImOffsetRect operator*(const ImOffsetRect& lhs, const ImOffsetRect& rhs) { return ImOffsetRect(lhs.Top * rhs.Top, lhs.Left * rhs.Left, lhs.Bottom * rhs.Bottom, lhs.Right * rhs.Right); } 42 | IM_MSVC_RUNTIME_CHECKS_RESTORE 43 | -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_toggle.cpp: -------------------------------------------------------------------------------- 1 | #include "imgui_toggle.h" 2 | 3 | #include "imgui.h" 4 | #include "imgui_toggle_math.h" 5 | #include "imgui_toggle_palette.h" 6 | #include "imgui_toggle_renderer.h" 7 | 8 | #ifndef IMGUI_DEFINE_MATH_OPERATORS 9 | #define IMGUI_DEFINE_MATH_OPERATORS 10 | #endif // IMGUI_DEFINE_MATH_OPERATORS 11 | #include "imgui_internal.h" 12 | 13 | using namespace ImGuiToggleConstants; 14 | using namespace ImGuiToggleMath; 15 | 16 | namespace 17 | { 18 | bool ToggleInternal(const char* label, bool* value, const ImGuiToggleConfig& config); 19 | 20 | // sets the given config structure's values to the 21 | // default ones used by the `Toggle()` overloads. 22 | inline void SetToAliasDefaults(ImGuiToggleConfig& config) 23 | { 24 | config.Flags = ImGuiToggleFlags_Default; 25 | config.AnimationDuration = AnimationDurationDisabled; 26 | config.FrameRounding = FrameRoundingDefault; 27 | config.KnobRounding = KnobRoundingDefault; 28 | } 29 | 30 | // thread-local data for the `Toggle()` functions to easily call `ToggleInternal()`. 31 | static thread_local ImGuiToggleConfig _internalConfig; 32 | } // namespace 33 | 34 | bool ImGui::Toggle(const char* label, bool* v, const ImVec2& size /*= ImVec2()*/) 35 | { 36 | ::SetToAliasDefaults(::_internalConfig); 37 | return ::ToggleInternal(label, v, ::_internalConfig); 38 | } 39 | 40 | bool ImGui::Toggle(const char* label, bool* v, ImGuiToggleFlags flags, const ImVec2& size /*= ImVec2()*/) 41 | { 42 | ::SetToAliasDefaults(::_internalConfig); 43 | ::_internalConfig.Flags = flags; 44 | ::_internalConfig.Size = size; 45 | 46 | // if the user is using any animation flags, 47 | // set the default animation duration. 48 | if ((flags & ImGuiToggleFlags_Animated) != 0) 49 | { 50 | _internalConfig.AnimationDuration = AnimationDurationDefault; 51 | } 52 | 53 | return ::ToggleInternal(label, v, ::_internalConfig); 54 | } 55 | 56 | bool ImGui::Toggle(const char* label, bool* v, ImGuiToggleFlags flags, float animation_duration, const ImVec2& size /*= ImVec2()*/) 57 | { 58 | // this overload implies the toggle should be animated. 59 | if (animation_duration > 0 && (flags & ImGuiToggleFlags_Animated) != 0) 60 | { 61 | // if the user didn't specify ImGuiToggleFlags_Animated, enable it. 62 | flags = flags | (ImGuiToggleFlags_Animated); 63 | } 64 | 65 | ::SetToAliasDefaults(::_internalConfig); 66 | ::_internalConfig.Flags = flags; 67 | ::_internalConfig.AnimationDuration = animation_duration; 68 | ::_internalConfig.Size = size; 69 | 70 | return ::ToggleInternal(label, v, ::_internalConfig); 71 | } 72 | 73 | bool ImGui::Toggle(const char* label, bool* v, ImGuiToggleFlags flags, float frame_rounding, float knob_rounding, const ImVec2& size /*= ImVec2()*/) 74 | { 75 | ::SetToAliasDefaults(::_internalConfig); 76 | ::_internalConfig.Flags = flags; 77 | ::_internalConfig.FrameRounding = frame_rounding; 78 | ::_internalConfig.KnobRounding = knob_rounding; 79 | ::_internalConfig.Size = size; 80 | 81 | return ::ToggleInternal(label, v, ::_internalConfig); 82 | } 83 | 84 | bool ImGui::Toggle(const char* label, bool* v, ImGuiToggleFlags flags, float animation_duration, float frame_rounding, float knob_rounding, const ImVec2& size /*= ImVec2()*/) 85 | { 86 | // this overload implies the toggle should be animated. 87 | if (animation_duration > 0 && (flags & ImGuiToggleFlags_Animated) != 0) 88 | { 89 | // if the user didn't specify ImGuiToggleFlags_Animated, enable it. 90 | flags = flags | (ImGuiToggleFlags_Animated); 91 | } 92 | 93 | ::_internalConfig.Flags = flags; 94 | ::_internalConfig.AnimationDuration = animation_duration; 95 | ::_internalConfig.FrameRounding = frame_rounding; 96 | ::_internalConfig.KnobRounding = knob_rounding; 97 | ::_internalConfig.Size = size; 98 | 99 | return ::ToggleInternal(label, v, ::_internalConfig); 100 | } 101 | 102 | bool ImGui::Toggle(const char* label, bool* v, const ImGuiToggleConfig& config) 103 | { 104 | return ::ToggleInternal(label, v, config); 105 | } 106 | 107 | namespace 108 | { 109 | bool ToggleInternal(const char* label, bool* v, const ImGuiToggleConfig& config) 110 | { 111 | static thread_local ImGuiToggleRenderer renderer; 112 | renderer.SetConfig(label, v, config); 113 | return renderer.Render(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_toggle_math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "imgui.h" 4 | 5 | #ifndef IMGUI_DEFINE_MATH_OPERATORS 6 | #define IMGUI_DEFINE_MATH_OPERATORS 7 | #endif // IMGUI_DEFINE_MATH_OPERATORS 8 | #include "imgui_internal.h" 9 | 10 | namespace ImGuiToggleMath 11 | { 12 | // lerp, but backwards! 13 | template constexpr inline T ImInvLerp(T a, T b, float value) { return (T)((value - a) / (b - a)); } 14 | 15 | // float comparison w/tolerance - can't constexper as ImFabs isn't constexpr. 16 | inline bool ImApproximately(float a, float b, float tolerance = 0.0001f) { return ImAbs(a - b) < tolerance; } 17 | 18 | // helpers for checking if an ImVec4 is zero or not. 19 | constexpr inline bool IsZero(const ImVec4& v) { return v.w == 0 && v.x == 0 && v.y == 0 && v.z == 0; } 20 | constexpr inline bool IsNonZero(const ImVec4& v) { return v.w != 0 || v.x != 0 || v.y != 0 || v.z != 0; } 21 | } // namespace 22 | -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_toggle_palette.cpp: -------------------------------------------------------------------------------- 1 | #include "imgui_toggle_palette.h" 2 | #include "imgui_toggle_math.h" 3 | 4 | #include "imgui.h" 5 | #ifndef IMGUI_DEFINE_MATH_OPERATORS 6 | #define IMGUI_DEFINE_MATH_OPERATORS 7 | #endif // IMGUI_DEFINE_MATH_OPERATORS 8 | #include "imgui_internal.h" 9 | 10 | using namespace ImGuiToggleMath; 11 | 12 | void ImGui::UnionPalette(ImGuiTogglePalette* target, const ImGuiTogglePalette* candidate, const ImVec4 colors[], bool v) 13 | { 14 | 15 | target->Knob = colors[ImGuiCol_Text]; 16 | target->KnobHover = colors[ImGuiCol_Text]; 17 | target->Frame = colors[!v ? ImGuiCol_FrameBg : ImGuiCol_Button]; 18 | target->FrameHover = colors[!v ? ImGuiCol_FrameBgHovered : ImGuiCol_ButtonHovered]; 19 | target->FrameBorder = colors[ImGuiCol_Border]; 20 | target->FrameShadow = colors[ImGuiCol_BorderShadow]; 21 | target->KnobBorder = colors[ImGuiCol_Border]; 22 | target->KnobShadow = colors[ImGuiCol_BorderShadow]; 23 | target->A11yGlyph = colors[!v ? ImGuiCol_FrameBg : ImGuiCol_Text]; 24 | 25 | // if the user didn't provide a candidate, just provide the theme colored palette. 26 | if (candidate == nullptr) 27 | { 28 | return; 29 | } 30 | 31 | // if the user did provide a candidate, populate all non-zero colors 32 | #define GET_PALETTE_POPULATE_NONZERO(member) \ 33 | do { \ 34 | if (IsNonZero(candidate->member)) \ 35 | { \ 36 | target->member = candidate->member; \ 37 | } \ 38 | } while (0) 39 | 40 | GET_PALETTE_POPULATE_NONZERO(Knob); 41 | GET_PALETTE_POPULATE_NONZERO(KnobHover); 42 | GET_PALETTE_POPULATE_NONZERO(Frame); 43 | GET_PALETTE_POPULATE_NONZERO(FrameHover); 44 | GET_PALETTE_POPULATE_NONZERO(FrameBorder); 45 | GET_PALETTE_POPULATE_NONZERO(FrameShadow); 46 | GET_PALETTE_POPULATE_NONZERO(KnobBorder); 47 | GET_PALETTE_POPULATE_NONZERO(KnobShadow); 48 | GET_PALETTE_POPULATE_NONZERO(A11yGlyph); 49 | 50 | #undef GET_PALETTE_POPULATE_NONZERO 51 | } 52 | 53 | void ImGui::BlendPalettes(ImGuiTogglePalette* result, const ImGuiTogglePalette& a, const ImGuiTogglePalette& b, float blend_amount) 54 | { 55 | // a quick out for if we are at either end of the blend. 56 | if (ImApproximately(blend_amount, 0.0f)) 57 | { 58 | *result = a; 59 | return; 60 | } 61 | else if (ImApproximately(blend_amount, 1.0f)) 62 | { 63 | *result = b; 64 | return; 65 | } 66 | 67 | 68 | #define BLEND_PALETTES_LERP(member) \ 69 | do { \ 70 | result->member = ImLerp(a.member, b.member, blend_amount); \ 71 | } while (0) 72 | 73 | BLEND_PALETTES_LERP(Knob); 74 | BLEND_PALETTES_LERP(KnobHover); 75 | BLEND_PALETTES_LERP(Frame); 76 | BLEND_PALETTES_LERP(FrameHover); 77 | BLEND_PALETTES_LERP(FrameBorder); 78 | BLEND_PALETTES_LERP(FrameShadow); 79 | BLEND_PALETTES_LERP(KnobBorder); 80 | BLEND_PALETTES_LERP(KnobShadow); 81 | BLEND_PALETTES_LERP(A11yGlyph); 82 | 83 | #undef BLEND_PALETTES_LERP 84 | } 85 | -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_toggle_palette.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "imgui.h" 4 | 5 | // ImGuiTogglePalette: A collection of colors used to customize the rendering of a toggle widget. 6 | // Leaving any ImVec4 as default (zero) will allow the theme color to be used for that member. 7 | struct ImGuiTogglePalette 8 | { 9 | // The default knob color. 10 | ImVec4 Knob; 11 | 12 | // The default knob color, used when when the knob is hovered. 13 | ImVec4 KnobHover; 14 | 15 | // The background color of the toggle frame. 16 | ImVec4 Frame; 17 | 18 | // The background color of the toggle frame when the toggle is hovered. 19 | ImVec4 FrameHover; 20 | 21 | // The background color of the toggle frame's border used when ImGuiToggleFlags_BorderedFrame is specified. 22 | ImVec4 FrameBorder; 23 | 24 | // The shadow color of the toggle frame. 25 | ImVec4 FrameShadow; 26 | 27 | // The background color of the toggle knob's border used when ImGuiToggleFlags_BorderedKnob is specified. 28 | ImVec4 KnobBorder; 29 | 30 | // The shadow color of the toggle knob. 31 | ImVec4 KnobShadow; 32 | 33 | // The color of the accessibility label or glyph. 34 | ImVec4 A11yGlyph; 35 | }; 36 | 37 | namespace ImGui 38 | { 39 | void UnionPalette(ImGuiTogglePalette* target, const ImGuiTogglePalette* candidate, const ImVec4 colors[], bool v); 40 | void BlendPalettes(ImGuiTogglePalette* result, const ImGuiTogglePalette& a, const ImGuiTogglePalette& b, float blend_amount); 41 | } 42 | -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_toggle_presets.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "imgui_toggle.h" 4 | 5 | // ImGuiTogglePresets: A few canned configurations for various presets OOTB. 6 | namespace ImGuiTogglePresets 7 | { 8 | // The default, unmodified style. 9 | ImGuiToggleConfig DefaultStyle(); 10 | 11 | // A style similar to default, but with rectangular knob and frame. 12 | ImGuiToggleConfig RectangleStyle(); 13 | 14 | // A style that uses a shadow to appear to glow while it's on. 15 | ImGuiToggleConfig GlowingStyle(); 16 | 17 | // A style that emulates what a toggle on iOS looks like. 18 | ImGuiToggleConfig iOSStyle(float size_scale = 1.0f, bool light_mode = false); 19 | 20 | // A style that emulates what a Material Design toggle looks like. 21 | ImGuiToggleConfig MaterialStyle(float size_scale = 1.0f); 22 | 23 | // A style that emulates what a toggle close to one from Minecraft. 24 | ImGuiToggleConfig MinecraftStyle(float size_scale = 1.0f); 25 | } 26 | -------------------------------------------------------------------------------- /Mod/imgui/toggle/imgui_toggle_renderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef IMGUI_DEFINE_MATH_OPERATORS 4 | #define IMGUI_DEFINE_MATH_OPERATORS 5 | #endif // IMGUI_DEFINE_MATH_OPERATORS 6 | 7 | #include "imgui.h" 8 | #include "imgui_toggle.h" 9 | #include "imgui_toggle_palette.h" 10 | 11 | #include "imgui_internal.h" 12 | 13 | class ImGuiToggleRenderer 14 | { 15 | public: 16 | ImGuiToggleRenderer(); 17 | ImGuiToggleRenderer(const char* label, bool* value, const ImGuiToggleConfig& user_config); 18 | void SetConfig(const char* label, bool* value, const ImGuiToggleConfig& user_config); 19 | bool Render(); 20 | 21 | private: 22 | // toggle state & context 23 | ImGuiToggleConfig _config; 24 | ImGuiToggleStateConfig _state; 25 | ImGuiTogglePalette _palette; 26 | 27 | bool _isMixedValue; 28 | bool _isHovered; 29 | bool _isLastActive; 30 | float _lastActiveTimer; 31 | float _animationPercent; 32 | 33 | // imgui specific context 34 | const ImGuiContext* g; 35 | const ImGuiStyle* _style; 36 | ImDrawList* _drawList; 37 | ImGuiID _id; 38 | 39 | // raw ui value & label 40 | const char* _label; 41 | bool* _value; 42 | 43 | // calculated values 44 | ImRect _boundingBox; 45 | ImVec4 _colorA11yGlyphOff; 46 | ImVec4 _colorA11yGlyphOn; 47 | 48 | // inline accessors 49 | inline float GetWidth() const { return _boundingBox.GetWidth(); } 50 | inline float GetHeight() const { return _boundingBox.GetHeight(); } 51 | inline ImVec2 GetPosition() const { return _boundingBox.Min; } 52 | inline ImVec2 GetToggleSize() const { return _boundingBox.GetSize(); } 53 | inline bool IsAnimated() const { return (_config.Flags & ImGuiToggleFlags_Animated) != 0 && _config.AnimationDuration > 0; } 54 | inline bool HasBorderedFrame() const { return (_config.Flags & ImGuiToggleFlags_BorderedFrame) != 0 && _state.FrameBorderThickness > 0; } 55 | inline bool HasShadowedFrame() const { return (_config.Flags & ImGuiToggleFlags_ShadowedKnob) != 0 && _state.FrameShadowThickness > 0; } 56 | inline bool HasBorderedKnob() const { return (_config.Flags & ImGuiToggleFlags_BorderedKnob) != 0 && _state.KnobBorderThickness > 0; } 57 | inline bool HasShadowedKnob() const { return (_config.Flags & ImGuiToggleFlags_ShadowedKnob) != 0 && _state.KnobShadowThickness > 0; } 58 | inline bool HasA11yGlyphs() const { return (_config.Flags & ImGuiToggleFlags_A11y) != 0; } 59 | inline bool HasCircleKnob() const { return _config.KnobRounding >= 1.0f; } 60 | inline bool HasRectangleKnob() const { return _config.KnobRounding < 1.0f; } 61 | 62 | // behavior 63 | void ValidateConfig(); 64 | bool ToggleBehavior(const ImRect& interaction_bounding_box); 65 | 66 | // drawing - general 67 | void DrawToggle(); 68 | 69 | // drawing - frame 70 | void DrawFrame(ImU32 color_frame); 71 | 72 | // drawing a11y 73 | void DrawA11yDot(const ImVec2& pos, ImU32 color); 74 | void DrawA11yGlyph(ImVec2 pos, ImU32 color, bool state, float radius, float thickness); 75 | void DrawA11yLabel(ImVec2 pos, ImU32 color, const char* label); 76 | void DrawA11yFrameOverlay(float knob_radius, bool state); 77 | void DrawA11yFrameOverlays(float knob_radius); 78 | 79 | // drawing - knob 80 | void DrawCircleKnob(float radius, ImU32 color_knob); 81 | void DrawRectangleKnob(float radius, ImU32 color_knob); 82 | 83 | // drawing - label 84 | void DrawLabel(float x_offset); 85 | 86 | // state updating 87 | void UpdateAnimationPercent(); 88 | void UpdateStateConfig(); 89 | void UpdatePalette(); 90 | 91 | // helpers 92 | ImVec2 CalculateKnobCenter(float radius, float animation_percent, const ImVec2& offset = ImVec2()) const; 93 | ImRect CalculateKnobBounds(float radius, float animation_percent, const ImVec2& offset = ImVec2()) const; 94 | void DrawRectBorder(ImRect bounds, ImU32 color_border, float rounding, float thickness); 95 | void DrawCircleBorder(const ImVec2& center, float radius, ImU32 color_border, float thickness); 96 | void DrawRectShadow(ImRect bounds, ImU32 color_shadow, float rounding, float thickness); 97 | void DrawCircleShadow(const ImVec2& center, float radius, ImU32 color_shadow, float thickness); 98 | }; 99 | -------------------------------------------------------------------------------- /Mod/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cngege/Mod/bb1c3ae96d33438e9d6a544a3b9855e86cb21284/Mod/resource.h -------------------------------------------------------------------------------- /Mod/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define VERSION_MAJOR 1 4 | #define VERSION_MINOR 8 5 | #define VERSION_REVISION 2 6 | #define VERSION_BUILD 0 7 | 8 | #define PLUGIN_NAME "Mod" 9 | #define PLUGIN_INTRODUCTION "Minecraft Windows Win10 Mod" 10 | #define PLUGIN_AUTHOR "CNGEGE" 11 | 12 | #define VS_FLAG_DEBUG 0x1L 13 | #define VS_FLAG_RELEASE 0x0L 14 | 15 | #define __TO_VERSION_STRING(ver) #ver 16 | #define TO_VERSION_STRING(ver) __TO_VERSION_STRING(ver) 17 | #define FILE_VERSION_STRING TO_VERSION_STRING(VERSION_MAJOR.VERSION_MINOR.VERSION_REVISION.VERSION_BUILD) 18 | 19 | #ifdef _DEBUG 20 | #define FILE_VERSION_FLAG VS_FLAG_DEBUG 21 | #else 22 | #define FILE_VERSION_FLAG VS_FLAG_RELEASE 23 | #endif 24 | 25 | #define VERSION_FLAG_STR_REPAIR " - Repair" 26 | #define VERSION_FLAG_STR_DEBUG " - Debug" 27 | #define VERSION_FLAG_STR_RELEASE " - Release" 28 | 29 | #ifdef _REPAIR 30 | #define VERSION_FLAG_STR VERSION_FLAG_STR_REPAIR 31 | #elif _DEBUG 32 | #define VERSION_FLAG_STR VERSION_FLAG_STR_DEBUG 33 | #else 34 | #define VERSION_FLAG_STR VERSION_FLAG_STR_RELEASE 35 | #endif 36 | 37 | #define FILE_VERSION_COMPANY_NAME PLUGIN_AUTHOR 38 | #define FILE_VERSION_LEGAL_COPYRIGHT "Copyright (C) 2022" 39 | #define FILE_VERSION_FILE_VERSION_STRING FILE_VERSION_STRING 40 | #define FILE_VERSION_INTERNAL_NAME PLUGIN_NAME 41 | #define FILE_VERSION_ORIGINAL_FILENAME PLUGIN_NAME ".dll" 42 | #define FILE_VERSION_PRODUCT_NAME FILE_VERSION_INTERNAL_NAME 43 | #define FILE_VERSION_PRODUCT_VERSION_STRING FILE_VERSION_STRING VERSION_FLAG_STR 44 | #define FILE_VERSION_FILE_DESCRIPTION PLUGIN_INTRODUCTION 45 | #define FILE_VERSION_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD 46 | #define FILE_VERSION_PRODUCT_VERSION FILE_VERSION_FILE_VERSION 47 | 48 | 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraft C++ Mod 2 | ### **🍁开发** 3 | 关于游戏更新时特征码的查找以及 偏移的查找等 4 | 已将相关方案记录在[Wiki](https://github.com/cngege/Mod/wiki)中, 开发者以及合作开发者请阅读 5 | 6 | ### **🚀功能更新** 7 | 8 | - **当前已实现功能** 9 | - 下落无伤害(目前仅本地房间) 10 | - 碰撞箱(**大写锁定**=开启,反之关闭) 11 | - 空气跳(可以在空中无限跳跃) 12 | - 瞬间破坏(按下 **SHIFT+CTRL** 时再破坏将瞬间破坏) 13 | - 向前挺进一格 可穿过一层墙(**F2**开启关闭,**鼠标中键**触发) 14 | - 强制显示坐标 15 | - 坐标点,可记录(**CTRL+F3**)、传送(**SHIFT+F3**) 16 | - ImGui绘制UI绘制文字 渲染面板 (**INSERT**) 17 | - 抗击退(只有在开启后长按**CTRL键**时抗击退,开关快捷键:**CTRL+F4**) 18 | - 好友检查,(**SHIFT+F4**)开启后通过玩家名称判断是否是好友,来拦截攻击(防止误伤),HitBox也不对好友产生影响 19 | - 自动疾跑模块 (**Ctrl+F6**) 默认开启,开启后,玩家移动即会自动奔跑 20 | - 玩家雷达(**SHIST+F6**)默认开启,开启后在右下角显示一个Box,以对应颜色显示所有玩家(能够触发Tick的玩家) 21 | - HiveTreasurePos Hive起床中使用(**F7**)开启后在小宝箱附近下蹲,将小宝箱传送至玩家位置 22 | - FastViewPerspective 长按快捷键显示第二人称视野,松开恢复 (**(鼠标侧键)F9**) 23 | - 攻击距离 = 7 (**SHIFT+F10**) 24 | - 点击显示实体名称和血量(**CTRL+F10**) 25 | - 多倍的物品掉落(仅本地房间,对多人有效) 26 | - **已经实现的其他功能** 27 | - ImGui面板UI用中文 28 | - ImGUi配置等选项信息能够保存本地 29 | - 配置保存本地,模块开启关闭状态保持本地 30 | - 模块的参数(比如攻击距离,碰撞箱大小)可以在UI中调节,且可保存到本地配置 31 | - 下载字体到本地 作为UI字体使用,UI字体暂不可选择 32 | - **将要更新的功能** 33 | - NoFound 34 | - **可能更新的功能** 35 | - 发送消息翻译成指定的语言(**缺少可翻译api**) 36 | - 命令系统(**等先实现在本地客户端上显示聊天消息的功能**) 37 | ### **👍已经解决的和未解决的BUG** 38 | - **已解决** 39 | - 日志乱码 40 | - 被断开连接时如果开启了`RenderHealth`模块,且正在显示玩家信息则会崩溃 41 | - **未解决** 42 | - 玩家雷达功能可能由于不正常的退出存档、房间导致不再显示 43 | ### **🐞项目开发** 44 | - **工具** 45 | - Visual Studio 2022 46 | 47 | ### **🎀技术参考(学习)** 48 | - **Horion-Open-SRC** 49 | - https://github.com/NRGJobro/Horion-Open-SRC/ 50 | - **YT Coding Internal Client** 51 | - https://www.youtube.com/playlist?list=PL9mZGNEJquY77cTy1eNOLs12BsVK5zA-P 52 | 53 | ### **🌿外部库** 54 | - **nlohmann::json** 55 | - https://github.com/nlohmann/json 56 | 57 | - **minhook** 58 | - https://github.com/TsudaKageyu/minhook 59 | 60 | - **Minecraft-DX12-Hook** (非常感谢) 61 | - https://github.com/NRGJobro/Minecraft-DX12-Hook 62 | 63 | - **Dear ImGui** 64 | - https://github.com/ocornut/imgui 65 | -------------------------------------------------------------------------------- /SDK/AABB.cpp: -------------------------------------------------------------------------------- 1 | #include "AABB.h" 2 | 3 | 4 | AABB::AABB(const AABB& aabb) { 5 | min = vec3_t(aabb.min); 6 | max = vec3_t(aabb.max); 7 | } 8 | 9 | //IDA Pro AABB::getsize(); 10 | float AABB::getsize() { 11 | return (float)((float)((float)(*((float*)this + 4) - *((float*)this + 1)) 12 | + (float)(*((float*)this + 3) - *(float*)this)) 13 | + (float)(*((float*)this + 5) - *((float*)this + 2))) 14 | * 0.33333334f; 15 | } 16 | 17 | //IDA Pro AABB::isValid(); 18 | bool AABB::isValid() { 19 | return *((float*)this + 3) >= *(float*)this 20 | && *((float*)this + 4) >= *((float*)this + 1) 21 | && *((float*)this + 5) >= *((float*)this + 2); 22 | } 23 | 24 | vec3_t AABB::getCenter() { 25 | vec3_t center; 26 | center.x = (this->max.x - this->min.x) * 0.5f + this->min.x; 27 | center.y = (this->max.y - this->min.y) * 0.5f + this->min.y; 28 | center.z = (this->max.z - this->min.z) * 0.5f + this->min.z; 29 | return center; 30 | } 31 | 32 | //IDA Pro AABB::getVolume; 33 | float AABB::getVolume() { 34 | return (float)((float)(*((float*)this + 4) - *((float*)this + 1)) * (float)(*((float*)this + 3) - *(float*)this)) 35 | * (float)(*((float*)this + 5) - *((float*)this + 2)); 36 | } 37 | 38 | vec3_t AABB::getBounds() { 39 | vec3_t bounds; 40 | bounds.x = this->max.x - this->min.x; 41 | bounds.y = this->max.y - this->min.y; 42 | bounds.z = this->max.z - this->min.z; 43 | return bounds; 44 | } 45 | 46 | inline bool AABB::operator==(const AABB& rhs) const { 47 | return min == rhs.min && max == rhs.max; 48 | } 49 | 50 | inline bool AABB::operator!=(const AABB& rhs) const { 51 | return min != rhs.min || max != rhs.max; 52 | } -------------------------------------------------------------------------------- /SDK/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\Mod\Utils\HMath.h" 3 | 4 | class AABB { 5 | public: 6 | vec3_t min; 7 | vec3_t max; 8 | public: 9 | AABB() {}; 10 | AABB(vec3_t _min, vec3_t _max) { min = _min; max = _max; }; 11 | AABB(const AABB& aabb); 12 | auto getsize()->float; 13 | auto isValid()->bool; 14 | auto getCenter()->vec3_t; 15 | auto getVolume()->float; //获取体积 16 | auto getBounds()->vec3_t; //获取边框 17 | inline bool operator==(const AABB& rhs) const; 18 | inline bool operator!=(const AABB& rhs) const; 19 | }; -------------------------------------------------------------------------------- /SDK/Actor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "..\Mod\Utils\HMath.h" 4 | 5 | #include "mcstring.h" 6 | #include "AttributeInstance.h" 7 | 8 | #include "../Hook/HookFunction.h" 9 | 10 | template 11 | class AutomaticID { 12 | T id; 13 | 14 | public: 15 | AutomaticID() { 16 | id = 0; 17 | } 18 | 19 | AutomaticID(T x) { 20 | id = x; 21 | } 22 | 23 | inline operator T() const { 24 | return id; 25 | } 26 | }; 27 | 28 | enum ActorType { 29 | player = 1, 30 | iron_golem = 788, 31 | panda = 9477, 32 | parrot = 21278, 33 | villager = 16778099, 34 | 35 | Hive_Treasure = 256 36 | }; 37 | 38 | enum class ActorFlags : int64_t { 39 | isSneaking = 1, 40 | isSprinting = 3, 41 | canFly = 21 // 这就是直接从 bds里看来的 Actor::canFly内部( 未检验->不是21 42 | }; 43 | 44 | class Actor 45 | { 46 | protected: 47 | static uintptr_t** vfTables; 48 | public: 49 | template 50 | static auto GetVFtableFun(int)->auto*; 51 | static auto GetVFtableFun(int)->uintptr_t*; 52 | static auto GetVFtables()->uintptr_t**; 53 | static auto SetVFtables(uintptr_t** vTables)->void; 54 | 55 | public: 56 | 57 | static int AABBOffset; 58 | //static int PosXOffset1; 59 | //static int PosYOffset1; 60 | //static int PosZOffset1; 61 | //static int PosXOffset2; 62 | //static int PosYOffset2; 63 | //static int PosZOffset2; 64 | 65 | //static int XHitBoxOffset; 66 | //static int YHitBoxOffset; 67 | 68 | static int LevelOffset; 69 | static int IsRemovedOffset; 70 | static int GetRotationOffset; 71 | 72 | static int GetAttributeInstance_HealthFunVT; 73 | //static uintptr_t isSneakingCallptr; 74 | static uintptr_t* setVelocityCallptr; 75 | static uintptr_t* getShadowRadiusCallptr; 76 | static uintptr_t* isInWaterCallptr; 77 | static uintptr_t* isInvisibleCallptr; 78 | 79 | // 使用特征码直接找到的函数地址 80 | static uintptr_t* getDimensionConstCallptr; 81 | 82 | 83 | public: 84 | 85 | auto isPlayerEx()->bool; 86 | 87 | public: 88 | 89 | auto getAABB()->class AABB*; 90 | auto getPosEx()->vec3_t; 91 | auto getPosEx2()->vec3_t; 92 | [[deprecated]] 93 | auto setPosEx(vec3_t)->void; 94 | 95 | auto getHitBox()->vec2_t; 96 | auto setHitBox(vec2_t)->void; 97 | auto resetHitBox()->void; 98 | auto getLevel()->class Level*; 99 | auto getActorCollision() -> class ActorCollision*; //this + 8bit 100 | auto getDimensionBlockSource() -> class BlockSource*; 101 | auto getTypeName() -> std::mcstring*; 102 | 103 | public: 104 | //auto onMoveBBs(vec3_t)->void; 105 | auto isLocalPlayerEx()->bool; 106 | auto getHealth()->float; 107 | auto isSneaking()->bool; 108 | auto isRemovedEx()->bool; 109 | auto getRotationEx()->vec2_t*; 110 | auto isValid()->bool; 111 | public: 112 | /* 原版函数 通过特征码获取 */ 113 | auto getDimensionConst()->class Dimension*; 114 | auto setPos(vec3_t*) -> void*; 115 | auto setPosPrev(vec3_t*) -> void*; 116 | auto getMovementProxy() -> class ActorMovementProxy*; 117 | auto getOrCreateUniqueID() -> int*; 118 | public: 119 | // Hook的函数 120 | auto setVelocity(vec3_t*)->void*; /*46*/ 121 | /** 122 | * @brief 是隐形的 123 | * @return 124 | */ 125 | auto isInvisible() -> bool; /*52*/ 126 | auto isInWater()->bool; /*73*/ 127 | auto getShadowRadius()->float; /*79*/ 128 | public: 129 | 130 | //原生虚表函数 131 | auto getStatusFlag(ActorFlags) -> bool; /*0*/ 132 | auto setStatusFlag(ActorFlags,bool)->void; /*1*/ 133 | 134 | auto getPosition()->vec3_t*; /*21*/ 135 | [[deprecated]] 136 | auto getPosPrev()->vec3_t*; /*22*/ 137 | //设置玩家移动的方向 这个函数在1.19.50.02 版本开始没有了 138 | //auto setRot(vec2_t*)->void; /*26*/ 139 | auto teleportTo(vec3_t* pos, bool a1, unsigned int a2, unsigned int a3)->void; /*43*/ 140 | auto getNameTag()-> std::mcstring*; /*62*/ 141 | auto isPlayer()->bool; /*67*/ // 因为MC中该函数功能的实现方法是 Player类重写,现在由类地址获取虚表获取该函数地址 142 | 143 | //获取玩家的移动方向 该函数在1.19.50.02 版本开始没有了 144 | //auto getRotation()->vec2_t*; /*81*/ 145 | auto setSneaking(bool)->void; /*87*/ // 1.20.15 146 | auto isOnFire() -> bool; /*91*/ 147 | auto isLocalPlayer() -> bool; /*95*/ // 1.20.30 148 | auto isRemotePlayer() -> bool; /*96*/ // 1.20.30 149 | auto getEntityTypeId() -> int; /*153*/ // 1.20.15 可能是 Player::getEntityTypeId() 150 | // 需要serverActor权限 151 | auto changeDimension(AutomaticID)->void; /*165*/ // 1.20.15 152 | auto checkFallDamage(float, bool) -> void*; /*167*/ // 1.20.15 153 | //auto causeFallDamage(float, float, class ActorDamageSource*)->void*; /*168*/ // 1.20.15 154 | auto isClientSide() -> bool; /*186*/ // 1.20.15 155 | auto getAttribute(Attribute) -> class AttributeInstance*; /*188*/ 156 | /*211*/ 157 | // Actor::setAuxValue(int) 158 | // Actor::resetUserPos(bool) 159 | // Actor::animateHurt(void) 160 | // Actor::onTame(void) 161 | // Actor::reloadHardcoded(enum Actor::InitializationMethod,class VariantParameterList const & __ptr64) 162 | // Actor::buildDebugInfo(class std::basic_string,class std::allocator > & __ptr64) 163 | // Actor::setEquippedSlot(enum EquipmentSlot,class ItemStack const & __ptr64) 164 | // Actor::healEffects(int) 165 | // Actor::playerTouch(class Player & __ptr64) 166 | // Actor::stopSpinAttack(void) 167 | // Actor::onBounceStarted(class BlockPos const & __ptr64,class Block const & __ptr64) 168 | // Actor::swing(void) 169 | // ... 170 | // Actor::setSleeping(bool) 171 | // Actor::changeDimension(class ChangeDimensionPacket const & __ptr64) 172 | auto setSize(float,float)->void; /*212*/ 173 | }; 174 | -------------------------------------------------------------------------------- /SDK/ActorCollision.cpp: -------------------------------------------------------------------------------- 1 | #include "ActorCollision.h" 2 | 3 | #include "Utils.h" 4 | #include "Logger.h" 5 | 6 | auto ActorCollision::getHealth() -> float 7 | { 8 | //三个特征码都在一个函数中,所以只要一个有用,就可以补全另外两个 9 | static auto offsetcall = FindSignature("E8 ? ? ? ? 85 ? 7F ? 48 8B CE E8 ? ? ? ? 84 ? 74 ? 48"); // 1.20.30.02 10 | if (offsetcall == 0x00) { 11 | logF_Debug("[ActorCollision.cpp] [ActorCollision::getHealth] [Warn] 第一个特征码失效"); 12 | offsetcall = FindSignature("E8 ? ? ? ? 85 ? 0F 8F ? ? ? ? 48 8D 95 ? ? ? ? 48 8B 4E ? E8"); 13 | if (offsetcall == 0x00) { 14 | logF_Debug("[ActorCollision.cpp] [ActorCollision::getHealth] [Warn] 第二个特征码失效"); 15 | offsetcall = FindSignature("E8 ? ? ? ? 85 ? 7F ? 48 8B 46 ? 48 8B 08 8B 46 ? 89"); 16 | } 17 | } 18 | _ASSERT(offsetcall); 19 | auto fun = Utils::FuncFromSigOffset(offsetcall, 1); 20 | using Fn = float(__fastcall*)(ActorCollision*); 21 | return reinterpret_cast(fun)(this); 22 | } 23 | 24 | // 确定 ActorCollision::setOnGround 25 | //----- (0000000142F02C20) ---------------------------------------------------- 26 | //char __fastcall sub_142F02C20(__int64 a1, char a2) 27 | //{ 28 | // int v2; // ebx 29 | // __int64* v3; // rcx 30 | // __int64* v5; // rax 31 | // int v6; // [rsp+38h] [rbp+10h] BYREF 32 | // 33 | // v2 = *(_DWORD*)(a1 + 8); 34 | // v3 = *(__int64**)a1; 35 | // if (a2) 36 | // { 37 | // v6 = v2; 38 | // return (unsigned __int8)sub_1407D7520(v3, &v6); 39 | // } 40 | // else 41 | // { 42 | // v5 = (__int64*)sub_1407DA270(*v3, 555691489); 43 | // v6 = v2; 44 | // return sub_140330060(v5, &v6); 45 | // } 46 | //} 47 | // 搜索保存C文件后搜索关键字:555691489); 然后和BDS版,上面的1.20.30版比较, 最后调用验证即可 48 | auto ActorCollision::setOnGround(bool onGround) -> char 49 | { 50 | // 直接定位call 51 | static auto funcall = FindSignature("40 53 48 83 EC ? 8B 59 ? 48 8B 09 84 D2 74 ? 48 8D 54 24 ? 89 5C 24 ? E8"); 52 | if (funcall == 0x00) { 53 | logF_Debug("[ActorCollision.cpp] [ActorCollision::setOnGround] [Warn] 第一个特征码失效"); 54 | // 调用者 55 | auto offset = FindSignature("E8 ? ? ? ? 48 8D 4F ? E8 ? ? ? ? 48 8B 07 48 8B CF 48 8B 80"); 56 | if (offset == 0x00) { 57 | logF_Debug("[ActorCollision.cpp] [ActorCollision::setOnGround] [Warn] 第二个特征码失效"); 58 | offset = FindSignature("E8 ? ? ? ? EB ? 0F B6 ? ? 48 8D 4F ? E8 ? ? ? ? 48"); 59 | if (offset == 0x00) { 60 | logF_Debug("[ActorCollision.cpp] [ActorCollision::setOnGround] [Warn] 第三个特征码失效"); 61 | offset = FindSignature("E8 ? ? ? ? 48 8B 1F 48 8B CF 48 8B 83 ? ? ? ? FF ? ? ? ? ? F3"); 62 | if (offset == 0x00) { 63 | // 没了 64 | } 65 | else { 66 | funcall = Utils::FuncFromSigOffset(offset, 1); 67 | } 68 | } 69 | else { 70 | funcall = Utils::FuncFromSigOffset(offset, 1); 71 | } 72 | } 73 | else { 74 | funcall = Utils::FuncFromSigOffset(offset, 1); 75 | } 76 | } 77 | _ASSERT(funcall); 78 | //auto fun = Utils::FuncFromSigOffset(offsetcall, 1); 79 | using Fn = char(__fastcall*)(ActorCollision*, bool); 80 | return reinterpret_cast(funcall)(this, onGround); 81 | } 82 | -------------------------------------------------------------------------------- /SDK/ActorCollision.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class ActorCollision { 5 | 6 | public: 7 | auto getHealth() -> float; 8 | auto setOnGround(bool) -> char; 9 | }; -------------------------------------------------------------------------------- /SDK/ActorMovementProxy.cpp: -------------------------------------------------------------------------------- 1 | #include "ActorMovementProxy.h" 2 | 3 | #include "Utils.h" 4 | #include "HMath.h" 5 | 6 | 7 | uintptr_t** ActorMovementProxy::vfTables = nullptr; 8 | 9 | template 10 | auto ActorMovementProxy::GetVFtableFun(int a)->auto* { 11 | return reinterpret_cast(vfTables[a]); 12 | } 13 | 14 | auto ActorMovementProxy::GetVFtableFun(int a)->uintptr_t* { 15 | return vfTables[a]; 16 | } 17 | 18 | auto ActorMovementProxy::GetVFtables()->uintptr_t** { 19 | return vfTables; 20 | } 21 | 22 | auto ActorMovementProxy::SetVFtables(uintptr_t** vfTable)->void { 23 | vfTables = vfTable; 24 | } 25 | 26 | 27 | uintptr_t** PlayerMovementProxy::vfTables = nullptr; 28 | 29 | template 30 | auto PlayerMovementProxy::GetVFtableFun(int a)->auto* { 31 | return reinterpret_cast(vfTables[a]); 32 | } 33 | 34 | auto PlayerMovementProxy::GetVFtableFun(int a)->uintptr_t* { 35 | return vfTables[a]; 36 | } 37 | 38 | auto PlayerMovementProxy::GetVFtables()->uintptr_t** { 39 | return vfTables; 40 | } 41 | 42 | auto PlayerMovementProxy::SetVFtables(uintptr_t** vfTable)->void { 43 | vfTables = vfTable; 44 | } 45 | 46 | 47 | auto ActorMovementProxy::getActor() -> class Actor* 48 | { 49 | return *reinterpret_cast((uintptr_t)this + 16); //offset 16byte 50 | } 51 | 52 | auto ActorMovementProxy::isOnGround() -> bool 53 | { 54 | return Utils::CallVFunc<39, bool>(this); 55 | } 56 | 57 | auto ActorMovementProxy::setOnGround(bool v) -> void 58 | { 59 | Utils::CallVFunc<40, void, bool>(this,v); 60 | } 61 | 62 | auto ActorMovementProxy::getHealth() -> int 63 | { 64 | return Utils::CallVFunc<43, int>(this); 65 | } 66 | 67 | auto ActorMovementProxy::getRotation() -> vec2_t* 68 | { 69 | return Utils::CallVFunc<51, vec2_t*>(this); //更新自 1.20.30 70 | } 71 | 72 | auto ActorMovementProxy::setRotation(vec2_t* rot) -> void 73 | { 74 | Utils::CallVFunc<52, void, vec2_t*>(this, rot); //更新自 1.20.30 75 | } 76 | 77 | auto ActorMovementProxy::getDimensionBlockSource() -> class BlockSource* 78 | { 79 | return Utils::CallVFunc<58, BlockSource*>(this); //更新自 1.20.30 80 | } 81 | -------------------------------------------------------------------------------- /SDK/ActorMovementProxy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | //const DirectActorMovementProxy::`vftable'{for `IActorMovementProxy'} 5 | class ActorMovementProxy { 6 | protected: 7 | static uintptr_t** vfTables; 8 | public: 9 | template 10 | static auto GetVFtableFun(int) -> auto*; 11 | static auto GetVFtableFun(int) -> uintptr_t*; 12 | static auto GetVFtables() -> uintptr_t**; 13 | static auto SetVFtables(uintptr_t** vTables) -> void; 14 | 15 | public: 16 | /**/ 17 | auto getActor() -> class Actor*; 18 | 19 | /*虚表函数*/ 20 | auto isOnGround() -> bool; /*39*/ //1.20.15 21 | auto setOnGround(bool) -> void; /*40*/ //1.20.15 22 | 23 | auto getHealth() -> int; /*43*/ //1.20.15 24 | auto getRotation() -> struct vec2_t*; /*73*/ //1.20.15 25 | auto setRotation(struct vec2_t*) ->void; /*74*/ //1.20.15 26 | auto getDimensionBlockSource() -> class BlockSource*; /*81*/ //1.20.15 27 | }; 28 | 29 | //DirectPlayerMovementProxy::`vftable'{for `IBoatMovementProxy'} 30 | class PlayerMovementProxy { 31 | protected: 32 | static uintptr_t** vfTables; 33 | public: 34 | template 35 | static auto GetVFtableFun(int) -> auto*; 36 | static auto GetVFtableFun(int) -> uintptr_t*; 37 | static auto GetVFtables() -> uintptr_t**; 38 | static auto SetVFtables(uintptr_t** vTables) -> void; 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /SDK/AttributeInstance.cpp: -------------------------------------------------------------------------------- 1 | #include "AttributeInstance.h" 2 | 3 | int AttributeInstance::getCurrentValueoffset = 33; 4 | 5 | auto AttributeInstance::getCurrentValue()->float { 6 | return *((float*)((char*)this + getCurrentValueoffset)); //这个偏移是偏移字节 7 | } -------------------------------------------------------------------------------- /SDK/AttributeInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum Attribute : __int64 { 4 | HEALTH = 25769804032, //25769804032 30064771328 06(int) 5 | MOVEMENT_SPEED = 38654705921 //来自 Player第292个虚表函数 Player::getSpeed 38654705921 6 | }; 7 | 8 | class AttributeInstance { 9 | public: 10 | static int getCurrentValueoffset; 11 | 12 | public: 13 | auto getCurrentValue()->float; 14 | }; 15 | -------------------------------------------------------------------------------- /SDK/Block.cpp: -------------------------------------------------------------------------------- 1 | #include "Block.h" 2 | #include "Utils.h" 3 | #include "BlockLegacy.h" 4 | 5 | auto Block::getBlockLegacy()->class BlockLegacy* { 6 | return *(BlockLegacy**)((uintptr_t)this + 48); //1.20.41 7 | } 8 | 9 | bool Block::isAir() 10 | { 11 | auto blockLegay = getBlockLegacy(); 12 | _ASSERT(blockLegay); 13 | return blockLegay->isAir(); 14 | } 15 | 16 | bool Block::isAirEx() 17 | { 18 | static SignCode sign("Block::isAirEx"); 19 | sign << "48 8B 48 ? 48 85 C9 0F 84 ? ? ? ? 48 8B ? 48 8B 80 ? ? ? ? FF 15 ? ? ? ? 84 ? 0F 85 ? ? ? ? 0F"; 20 | // ^ ^ 21 | _ASSERT(sign); 22 | int offsetA = (int)*reinterpret_cast(*sign + 3); 23 | int offsetB = *reinterpret_cast(*sign + 19); 24 | 25 | uintptr_t v1 = *(uintptr_t*)((uintptr_t)this + offsetA);//getBlockLegacy 26 | return reinterpret_cast(*(uintptr_t*)(*(uintptr_t*)v1 + offsetB))(v1);//BlockLegacy::isAir 27 | } 28 | -------------------------------------------------------------------------------- /SDK/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | class Block { 6 | public: 7 | class BlockLegacy* getBlockLegacy(); 8 | 9 | bool isAir(); 10 | bool isAirEx(); 11 | }; -------------------------------------------------------------------------------- /SDK/BlockLegacy.cpp: -------------------------------------------------------------------------------- 1 | #include "BlockLegacy.h" 2 | #include "Utils.h" 3 | 4 | //v14 = *(_WORD*)(v4 + 422); 5 | //if (v14 < 0x100u) 6 | // v15 = *(_WORD*)(v4 + 422); 7 | //else 8 | //v15 = 255 - v14; 9 | // 可搜索 < 0x100u ) 10 | //或者搜索"minecraft:yellow_flower" 有三处 在大函数内部, 在下面一点的地方有关键代码 11 | unsigned short BlockLegacy::getBlockItemIdEx() 12 | { 13 | static SignCode sign("BlockLegacy::getBlockItemIdEx"); 14 | sign.AddSign("0F B7 80 ? ? ? ? B9 00 01 00 00", [this](uintptr_t v) { return v + 3; }); 15 | _ASSERT(sign); 16 | // 关键这个422需要用特征码获取 17 | unsigned short id = *(unsigned short*)((uintptr_t)this + *(int*)*sign); 18 | if (id < 0x100u) 19 | return id; 20 | else 21 | return 255 - id; 22 | } 23 | 24 | bool BlockLegacy::isAir() 25 | { 26 | return Utils::CallVFunc<29, bool>(this); //1.20.41.02 27 | } 28 | -------------------------------------------------------------------------------- /SDK/BlockLegacy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class BlockLegacy { 5 | public: 6 | unsigned short getBlockItemIdEx(); 7 | 8 | 9 | 10 | // 虚表 11 | 12 | bool isAir(); 13 | }; 14 | -------------------------------------------------------------------------------- /SDK/BlockSource.cpp: -------------------------------------------------------------------------------- 1 | #include "BlockSource.h" 2 | 3 | #include "Utils.h" 4 | #include "HMath.h" 5 | 6 | // a = 0, 调用第二个虚函数, a = 1 调用 getExtraBlock, 否则返回空气方块 7 | auto BlockSource::getBlock(vec3_ti* BlockPos, int a) -> class Block* 8 | { 9 | return Utils::CallVFunc<1, Block*, vec3_ti*, int>(this, BlockPos,a); 10 | } 11 | 12 | auto BlockSource::getBlock(vec3_ti* BlockPos) -> class Block* 13 | { 14 | return Utils::CallVFunc<2, Block*, vec3_ti*>(this, BlockPos); 15 | } 16 | 17 | auto BlockSource::getBlock(int x, int y, int z) -> class Block* 18 | { 19 | return Utils::CallVFunc<3, Block*, int, int, int>(this, x, y, x); 20 | } 21 | 22 | auto BlockSource::getBlockEntity(vec3_ti* BlockPos) -> class BlockActor* 23 | { 24 | return Utils::CallVFunc<4, BlockActor*, vec3_ti*>(this, BlockPos); 25 | } 26 | 27 | auto BlockSource::hasBlock(vec3_ti* BlockPos) -> bool 28 | { 29 | return Utils::CallVFunc<7, bool, vec3_ti*>(this, BlockPos); 30 | } 31 | 32 | auto BlockSource::getBrightness(vec3_ti* BlockPos) -> float 33 | { 34 | return Utils::CallVFunc<20, float, vec3_ti*>(this, BlockPos); 35 | } 36 | 37 | auto BlockSource::isSolidBlockingBlock(int x, int y, int z) -> bool 38 | { 39 | return Utils::CallVFunc<37, bool, int, int, int>(this, x, y, x); 40 | } 41 | 42 | auto BlockSource::isSolidBlockingBlock(vec3_ti* BlockPos) -> bool 43 | { 44 | return Utils::CallVFunc<38, bool, vec3_ti*>(this, BlockPos); 45 | } 46 | -------------------------------------------------------------------------------- /SDK/BlockSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct vec3_ti; 5 | 6 | // XXBlock 继承于 BlockLegacy 7 | 8 | class BlockSource { 9 | public: 10 | auto getBlock(vec3_ti*, int) -> class Block*; /*1*/ // 1.20.15 11 | auto getBlock(vec3_ti*) -> class Block*; /*2*/ // 1.20.15 12 | auto getBlock(int, int, int)-> class Block*; /*3*/ // 1.20.15 13 | auto getBlockEntity(vec3_ti*) -> class BlockActor*; /*4*/ // 1.20.15 14 | 15 | auto hasBlock(vec3_ti*) -> bool; /*7*/ // 1.20.15 16 | 17 | // 获取亮度 18 | auto getBrightness(vec3_ti*) -> float; /*19*/ // 1.20.15 19 | 20 | // 是实体阻塞方块 21 | auto isSolidBlockingBlock(int, int, int) -> bool; /*36*/ // 1.20.15 22 | auto isSolidBlockingBlock(vec3_ti*) -> bool; /*37*/ // 1.20.15 23 | }; -------------------------------------------------------------------------------- /SDK/ClientInstance.cpp: -------------------------------------------------------------------------------- 1 | #include "ClientInstance.h" 2 | 3 | uintptr_t** ClientInstance::vfTables = nullptr; 4 | 5 | int ClientInstance::getMinecraftGameOffset = 0; 6 | 7 | 8 | template 9 | auto ClientInstance::GetVFtableFun(int a)->auto* { 10 | return reinterpret_cast(vfTables[a]); 11 | } 12 | 13 | auto ClientInstance::GetVFtableFun(int a)->uintptr_t* { 14 | return vfTables[a]; 15 | } 16 | 17 | auto ClientInstance::GetVFtables()->uintptr_t** { 18 | return vfTables; 19 | } 20 | 21 | auto ClientInstance::SetVFtables(uintptr_t** vfTable)->void { 22 | vfTables = vfTable; 23 | } 24 | 25 | // 偏移28*8 看Tick 其实Hook的Tick是frameUpdate, 其中调用了 LevelRenderer::frameUpdate, 在获取 LevelRenderer 中能看到偏移 26 | // 进行 Tick 函数,对比源码找 27 | //sub_14031AA40(a2, (__int64)a1); 28 | //v14 = a1[28]; 29 | //if (v14) 30 | //sub_1413A0200(v14, (__int64)&v19);//应该就是这个 31 | //v15 = (*(__int64(__fastcall**)(_QWORD*))(*a1 + 1616i64))(a1); 32 | //if (v15) 33 | //sub_1413E6090(v15, a2);//LightTexture::frameUpdate 34 | //v16 = a1[31]; 35 | //if (v16) 36 | //(*(void(__fastcall**)(__int64, __int64))(*(_QWORD*)v16 + 776i64))(v16, a2); 37 | //if (*((_QWORD*)&v20 + 1)) 38 | //sub_1400D0770(*((volatile signed __int32**)&v20 + 1)); 39 | 40 | //源码: 41 | //v8 = *((_QWORD*)this + 19); 42 | //if (v8) 43 | //LevelRenderer::frameUpdate(v8, (FrameUpdateContext*)v12); 44 | //v9 = (LightTexture*)(*(__int64(__fastcall**)(ClientInstance*))(*(_QWORD*)this + 1360LL))(this); 45 | //if (v9) 46 | //LightTexture::frameUpdate(v9, a2); 47 | //v10 = *((_QWORD*)this + 22); 48 | //if (v10) 49 | //(*(void(__fastcall**)(__int64, FrameUpdateContext*))(*(_QWORD*)v10 + 784LL))(v10, a2); 50 | //return __readfsqword(0x28u); 51 | 52 | // 其中 LightTexture::frameUpdate 中有明显的字符串可以定位到 "Brightness Texture Update" 53 | 54 | //第二个方法 首先通过 "A LevelRenderer group" 定位LevelRenderer构造函数,拿到虚表地址,(注意出现的第二个才是虚表地址) 55 | //然后看CI结构,在E0 左右看谁的指针虚表符合即可得到偏移 56 | LevelRenderer* ClientInstance::getLevelRender() { 57 | static SignCode sign("ClientInstance::getLevelRender"); //特征码获取偏移 58 | sign.AddSign("48 8B 8F ? ? ? ? 48 85 C9 74 ? 48 8D 54", [](uintptr_t v) { return v + 3; }); 59 | _ASSERT(sign); 60 | return *(LevelRenderer**)((uintptr_t)this + *reinterpret_cast(*sign)); 61 | } -------------------------------------------------------------------------------- /SDK/Dimension.cpp: -------------------------------------------------------------------------------- 1 | #include "Dimension.h" 2 | 3 | -------------------------------------------------------------------------------- /SDK/Dimension.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //a1->lpVtbl = (struct DimensionVtbl*)&Dimension::`vftable'{for `IDimension'}; 3 | //a1[1].lpVtbl = (struct DimensionVtbl*)&Dimension::`vftable'{for `LevelListener'}; 4 | //a1[2].lpVtbl = (struct DimensionVtbl*)&OverworldDimension::`vftable'{for `SavedData'}; 5 | //a1[8].lpVtbl = (struct DimensionVtbl*)&OverworldDimension::`vftable'{for `Bedrock::EnableNonOwnerReferences'}; 6 | #include "BlockSource.h" 7 | 8 | class Dimension { 9 | public: 10 | BlockSource* getBlockSourceEx() { 11 | return *(BlockSource**)((uintptr_t)this + 208); 12 | } 13 | }; -------------------------------------------------------------------------------- /SDK/FishingHook.cpp: -------------------------------------------------------------------------------- 1 | #include "FishingHook.h" 2 | 3 | uintptr_t** FishingHook::vfTables = nullptr; 4 | 5 | 6 | template 7 | auto FishingHook::GetVFtableFun(int a)->auto* { 8 | return reinterpret_cast(vfTables[a]); 9 | } 10 | 11 | auto FishingHook::GetVFtableFun(int a)->uintptr_t* { 12 | return vfTables[a]; 13 | } 14 | 15 | auto FishingHook::GetVFtables()->uintptr_t** { 16 | return vfTables; 17 | } 18 | 19 | auto FishingHook::SetVFtables(uintptr_t** vfTable)->void { 20 | vfTables = vfTable; 21 | } 22 | -------------------------------------------------------------------------------- /SDK/FishingHook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Actor.h" 3 | 4 | class FishingHook : public Actor 5 | { 6 | protected: 7 | static uintptr_t** vfTables; 8 | public: 9 | template 10 | static auto GetVFtableFun(int) -> auto*; 11 | static auto GetVFtableFun(int) -> uintptr_t*; 12 | static auto GetVFtables() -> uintptr_t**; 13 | static auto SetVFtables(uintptr_t** vTables) -> void; 14 | }; 15 | -------------------------------------------------------------------------------- /SDK/GameMode.cpp: -------------------------------------------------------------------------------- 1 | #include "GameMode.h" 2 | #include "Actor.h" 3 | 4 | uintptr_t** GameMode::vfTables = nullptr; 5 | 6 | uintptr_t* GameMode::startDestroyBlockCall = nullptr; 7 | uintptr_t* GameMode::attackCall = nullptr; 8 | uintptr_t* GameMode::tickCall = nullptr; 9 | uintptr_t* GameMode::useItemCall = nullptr; 10 | uintptr_t* GameMode::useItemOnCall = nullptr; 11 | 12 | template 13 | auto GameMode::GetVFtableFun(int a)->auto* { 14 | return reinterpret_cast(vfTables[a]); 15 | } 16 | 17 | auto GameMode::GetVFtableFun(int a)->uintptr_t* { 18 | return vfTables[a]; 19 | } 20 | 21 | auto GameMode::GetVFtables()->uintptr_t** { 22 | return vfTables; 23 | } 24 | 25 | auto GameMode::SetVFtables(uintptr_t** vfTable)->void { 26 | vfTables = vfTable; 27 | } 28 | 29 | 30 | auto GameMode::GetLocalPlayer()->LocalPlayer* { 31 | return *reinterpret_cast((uintptr_t)this + 8); //紧挨着虚表地址的就是本地玩家地址 32 | } 33 | 34 | 35 | //Hook后虚表函数的实现 36 | auto GameMode::startDestroyBlock(vec3_ti* Bpos, uint8_t* Face, void* a1,void* a2)->bool { 37 | using Fn = bool(__fastcall*)(GameMode*, vec3_ti*, uint8_t*,void*,void*); 38 | return reinterpret_cast(startDestroyBlockCall)(this, Bpos, Face,a1,a2); 39 | } 40 | 41 | auto GameMode::tick()->void* { 42 | using Fn = void*(__fastcall*)(GameMode*); 43 | return reinterpret_cast(tickCall)(this); 44 | } 45 | 46 | auto GameMode::attack(Actor* actor) ->bool { 47 | using Fn = bool(__fastcall*)(GameMode*, Actor*); 48 | return reinterpret_cast(attackCall)(this, actor); 49 | } 50 | 51 | auto GameMode::useItem(class ItemStack* item)->bool { 52 | using Fn = bool(__fastcall*)(GameMode*, class ItemStack*); 53 | return reinterpret_cast(useItemCall)(this, item); 54 | } 55 | 56 | auto GameMode::useItemOn(class ItemStack* item, class ItemInstance* itemins, vec3_ti* bpos, uint8_t* face, vec3_t* f, class Block* block)->bool { 57 | using Fn = bool(__fastcall*)(GameMode*, class ItemStack*, class ItemInstance* itemins, vec3_ti*, uint8_t*, vec3_t*, class Block*); 58 | return reinterpret_cast(useItemOnCall)(this, item, itemins, bpos, face, f, block); 59 | } 60 | 61 | //虚表函数实现 62 | 63 | //破坏方块 64 | auto GameMode::destroyBlock(vec3_ti* Bpos, uint8_t* Face)->bool { 65 | return GetVFtableFun(2)(this, Bpos, Face); 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /SDK/GameMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Mod/Utils/Utils.h" 3 | #include "../Mod/Utils/HMath.h" 4 | 5 | class GameMode { 6 | 7 | protected: 8 | static uintptr_t** vfTables; 9 | public: 10 | template 11 | static auto GetVFtableFun(int)->auto*; 12 | static auto GetVFtableFun(int)->uintptr_t*; 13 | static auto GetVFtables()->uintptr_t**; 14 | static auto SetVFtables(uintptr_t** vTables)->void; 15 | 16 | // 虚表函数被Hook后 具有原始功能的调用 17 | public: 18 | static uintptr_t* startDestroyBlockCall; 19 | static uintptr_t* attackCall; 20 | static uintptr_t* tickCall; 21 | static uintptr_t* useItemCall; 22 | static uintptr_t* useItemOnCall; 23 | 24 | public: 25 | auto GetLocalPlayer()->class LocalPlayer*; 26 | 27 | //调用具有原始功能的被Hook的函数 28 | public: 29 | 30 | auto startDestroyBlock(vec3_ti* Bpos, uint8_t* Face, void* a1, void* a2)->bool; /*1*/ 31 | auto tick()->void*; /*8*/ 32 | auto useItem(class ItemStack*)->bool; /*11*/ //对着空气右键 33 | auto useItemOn(class ItemStack*, class ItemInstance*, vec3_ti*, uint8_t*,vec3_t*, class Block*)->bool; /*12*/ //对着方块右键 34 | auto attack(class Actor*) ->bool; /*14*/ 35 | 36 | // 虚表函数 37 | public: 38 | 39 | auto destroyBlock(vec3_ti* Bpos, uint8_t* Face)->bool; /*2*/ 40 | }; 41 | -------------------------------------------------------------------------------- /SDK/GuiData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\Mod\Utils\HMath.h" 3 | #include 4 | 5 | class C_GuiData { 6 | public: 7 | private: 8 | char pad_0x0000[0x18]; //0x0000 9 | public: 10 | union { 11 | struct { 12 | float widthReal; //0x0018 13 | float heightReal; //0x001C 14 | }; 15 | vec2_t windowSizeReal; //0x0018 16 | }; 17 | 18 | float widthReal2; //0x0020 19 | float heightReal2; //0x0024 20 | union { 21 | struct { 22 | float widthGame; //0x0028 23 | float heightGame; //0x002C 24 | }; 25 | vec2_t windowSize; //0x0028 26 | }; 27 | 28 | float getGuiScale() { 29 | return *reinterpret_cast(reinterpret_cast(this) + 0x34); 30 | }; 31 | 32 | uint16_t getMouseX() { 33 | return *reinterpret_cast(reinterpret_cast(this) + 0x52); 34 | }; 35 | 36 | uint16_t getMouseY() { 37 | return *reinterpret_cast(reinterpret_cast(this) + 0x54); 38 | }; 39 | }; -------------------------------------------------------------------------------- /SDK/Item.cpp: -------------------------------------------------------------------------------- 1 | #include "Item.h" 2 | #include "Utils.h" 3 | #include "ItemStackBase.h" 4 | 5 | uintptr_t** Item::vfTables = nullptr; 6 | 7 | int Item::getIdOffset = 0; 8 | 9 | template 10 | auto Item::GetVFtableFun(int a)->auto* { 11 | return reinterpret_cast(vfTables[a]); 12 | } 13 | 14 | auto Item::GetVFtableFun(int a)->uintptr_t* { 15 | return vfTables[a]; 16 | } 17 | 18 | auto Item::GetVFtables()->uintptr_t** { 19 | return vfTables; 20 | } 21 | 22 | auto Item::SetVFtables(uintptr_t** vfTable)->void { 23 | vfTables = vfTable; 24 | } 25 | 26 | auto Item::isValid() -> bool 27 | { 28 | return this && *(void**)this; 29 | } 30 | 31 | auto Item::getIdEx()->short 32 | { 33 | return *reinterpret_cast((uintptr_t)this + getIdOffset); 34 | } 35 | 36 | 37 | // 检查版本 1.20 38 | auto Item::use(ItemStack* item, Player* player)->ItemStack* { 39 | using Fn = ItemStack*(__fastcall*)(Item*, ItemStack*, Player*); 40 | return reinterpret_cast((*(uintptr_t**)this)[84])(this, item, player); 41 | //return Utils::CallVFunc<84, ItemStack&, Item*, ItemStack&, Player&>(*(void**)this, this, item, player); 42 | } 43 | 44 | // 检查版本 1.20 45 | auto Item::buildDescriptionName(TextHolder& text, ItemStackBase item)->TextHolder& { 46 | //using Fn = TextHolder& (__fastcall*)(Item*, TextHolder&, ItemStackBase&); 47 | //return reinterpret_cast((*(uintptr_t**)this)[94])(this, text, item); 48 | return Utils::CallVFunc<94, TextHolder&, Item*, TextHolder&, ItemStackBase&>(*(void**)this, this, text, item); 49 | } -------------------------------------------------------------------------------- /SDK/Item.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\Mod\Utils\HMath.h" 3 | 4 | // 不是继承而来 5 | class Item { 6 | protected: 7 | static uintptr_t** vfTables; 8 | 9 | public: 10 | static int getIdOffset; 11 | public: 12 | template 13 | static auto GetVFtableFun(int) -> auto*; 14 | static auto GetVFtableFun(int) -> uintptr_t*; 15 | static auto GetVFtables() -> uintptr_t**; 16 | static auto SetVFtables(uintptr_t** vTables) -> void; 17 | public: 18 | auto isValid() -> bool; 19 | auto getIdEx() -> short; //5498 钓鱼竿id 20 | 21 | public: 22 | // 这个函数的下面就是 ItemStack::use 23 | class ItemStack* use(class ItemStack*, class Player*); /*84*/ 24 | class TextHolder& buildDescriptionName(class TextHolder&, class ItemStackBase); /*94*/ 25 | }; -------------------------------------------------------------------------------- /SDK/ItemInstance.cpp: -------------------------------------------------------------------------------- 1 | #include "ItemInstance.h" 2 | 3 | uintptr_t** ItemInstance::vfTables = nullptr; 4 | 5 | template 6 | auto ItemInstance::GetVFtableFun(int a)->auto* { 7 | return reinterpret_cast(vfTables[a]); 8 | } 9 | 10 | auto ItemInstance::GetVFtableFun(int a)->uintptr_t* { 11 | return vfTables[a]; 12 | } 13 | 14 | auto ItemInstance::GetVFtables()->uintptr_t** { 15 | return vfTables; 16 | } 17 | 18 | auto ItemInstance::SetVFtables(uintptr_t** vfTable)->void { 19 | vfTables = vfTable; 20 | } 21 | -------------------------------------------------------------------------------- /SDK/ItemInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ItemStackBase.h" 3 | 4 | class ItemInstance : public ItemStackBase { 5 | protected: 6 | static uintptr_t** vfTables; 7 | public: 8 | template 9 | static auto GetVFtableFun(int) -> auto*; 10 | static auto GetVFtableFun(int) -> uintptr_t*; 11 | static auto GetVFtables() -> uintptr_t**; 12 | static auto SetVFtables(uintptr_t** vTables) -> void; 13 | }; -------------------------------------------------------------------------------- /SDK/ItemStack.cpp: -------------------------------------------------------------------------------- 1 | #include "ItemStack.h" 2 | 3 | uintptr_t** ItemStack::vfTables = nullptr; 4 | 5 | uintptr_t* ItemStack::useCall = nullptr; 6 | 7 | template 8 | auto ItemStack::GetVFtableFun(int a)->auto* { 9 | return reinterpret_cast(vfTables[a]); 10 | } 11 | 12 | auto ItemStack::GetVFtableFun(int a)->uintptr_t* { 13 | return vfTables[a]; 14 | } 15 | 16 | auto ItemStack::GetVFtables()->uintptr_t** { 17 | return vfTables; 18 | } 19 | 20 | auto ItemStack::SetVFtables(uintptr_t** vfTable)->void { 21 | vfTables = vfTable; 22 | } 23 | 24 | auto ItemStack::use(Player* player) -> ItemStack* 25 | { 26 | using Fn = ItemStack * (__fastcall*)(ItemStack*, Player*); 27 | return reinterpret_cast(useCall)(this, player); 28 | } 29 | -------------------------------------------------------------------------------- /SDK/ItemStack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ItemStackBase.h" 3 | 4 | class ItemStack : public ItemStackBase { 5 | protected: 6 | static uintptr_t** vfTables; 7 | 8 | public: 9 | static uintptr_t* useCall; 10 | public: 11 | template 12 | static auto GetVFtableFun(int) -> auto*; 13 | static auto GetVFtableFun(int) -> uintptr_t*; 14 | static auto GetVFtables() -> uintptr_t**; 15 | static auto SetVFtables(uintptr_t** vTables) -> void; 16 | 17 | public: 18 | auto use(class Player*) -> ItemStack*; //特征码定位Call 19 | 20 | }; -------------------------------------------------------------------------------- /SDK/ItemStackBase.cpp: -------------------------------------------------------------------------------- 1 | #include "ItemStackBase.h" 2 | 3 | 4 | uintptr_t** ItemStackBase::vfTables = nullptr; 5 | 6 | template 7 | auto ItemStackBase::GetVFtableFun(int a)->auto* { 8 | return reinterpret_cast(vfTables[a]); 9 | } 10 | 11 | auto ItemStackBase::GetVFtableFun(int a)->uintptr_t* { 12 | return vfTables[a]; 13 | } 14 | 15 | auto ItemStackBase::GetVFtables()->uintptr_t** { 16 | return vfTables; 17 | } 18 | 19 | auto ItemStackBase::SetVFtables(uintptr_t** vfTable)->void { 20 | vfTables = vfTable; 21 | } 22 | 23 | Item* ItemStackBase::getItemEx() 24 | { 25 | return *reinterpret_cast((uintptr_t)this + 8); 26 | } 27 | -------------------------------------------------------------------------------- /SDK/ItemStackBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\Mod\Utils\HMath.h" 3 | 4 | class ItemStackBase { 5 | protected: 6 | static uintptr_t** vfTables; 7 | public: 8 | template 9 | static auto GetVFtableFun(int) -> auto*; 10 | static auto GetVFtableFun(int) -> uintptr_t*; 11 | static auto GetVFtables() -> uintptr_t**; 12 | static auto SetVFtables(uintptr_t** vTables) -> void; 13 | 14 | public: 15 | class Item* getItemEx(); 16 | }; -------------------------------------------------------------------------------- /SDK/Level.cpp: -------------------------------------------------------------------------------- 1 | #include "Level.h" 2 | #include "Utils.h" 3 | 4 | uintptr_t** Level::vfTables = nullptr; 5 | 6 | 7 | 8 | uintptr_t* Level::startLeaveGameCall = nullptr; 9 | //uintptr_t* Level::forEachPlayerCall = nullptr; 10 | uintptr_t* Level::tickCall = nullptr; 11 | 12 | 13 | template 14 | auto Level::GetVFtableFun(int a)->auto* { 15 | return reinterpret_cast(vfTables[a]); 16 | } 17 | 18 | auto Level::GetVFtableFun(int a)->uintptr_t* { 19 | return vfTables[a]; 20 | } 21 | 22 | auto Level::GetVFtables()->uintptr_t** { 23 | return vfTables; 24 | } 25 | 26 | auto Level::SetVFtables(uintptr_t** vfTable)->void { 27 | vfTables = vfTable; 28 | } 29 | 30 | 31 | auto Level::getAllPlayer()->std::vector { 32 | try { 33 | std::vector player_list; 34 | this->forEachPlayer([&](Player& sp) { 35 | Player* player = &sp; 36 | player_list.push_back(player); 37 | return true; 38 | }); 39 | return player_list; 40 | }catch (...) { 41 | return {}; 42 | } 43 | } 44 | 45 | 46 | auto Level::getTime()->int { 47 | return Utils::CallVFunc<111, int>(this); //更新自 1.20.30 48 | } 49 | 50 | auto Level::setTime(int time)->void { 51 | return Utils::CallVFunc<112, void,int>(this, time); //更新自 1.20.30 52 | } 53 | 54 | auto Level::getSeed() -> unsigned int 55 | { 56 | return Utils::CallVFunc<113, unsigned int>(this); //更新自 1.20.30 57 | } 58 | 59 | // 虚表Hook 60 | 61 | auto Level::startLeaveGame() -> void 62 | { 63 | using Fn = void(__fastcall*)(Level*); 64 | reinterpret_cast(startLeaveGameCall)(this); 65 | } 66 | 67 | auto Level::Tick() -> void* 68 | { 69 | try 70 | { 71 | using Fn = void* (__fastcall*)(Level*); 72 | return reinterpret_cast(tickCall)(this); 73 | } 74 | catch (const std::exception&) 75 | {} 76 | return nullptr; 77 | } 78 | 79 | // 207 Level::forEachPlayer(class std::function)const 取这个 80 | // 208 Level::forEachPlayer(class std::function) 81 | // 虚表 检查版本 1.20.30 82 | auto Level::forEachPlayer(std::function fp)->void { 83 | return Utils::CallVFunc<203, void, std::function>(this, fp); 84 | //return reinterpret_cast)>((*(uintptr_t**)this)[207])(this, fp); 85 | } 86 | 87 | auto Level::isClientSide() -> bool 88 | { 89 | return Utils::CallVFunc<287, bool>(this); //更新自 1.20.30 90 | } 91 | 92 | auto Level::setSimPaused(bool v) -> void 93 | { 94 | return Utils::CallVFunc<319, void, bool>(this, v); //更新自 1.20.30 95 | } 96 | 97 | auto Level::getSimPaused() -> bool 98 | { 99 | return Utils::CallVFunc<320, bool>(this); //更新自 1.20.30 100 | } 101 | -------------------------------------------------------------------------------- /SDK/Level.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | //LevelForILevel 已确定 6 | class Level { 7 | protected: 8 | static uintptr_t** vfTables; 9 | public: 10 | template 11 | static auto GetVFtableFun(int) -> auto*; 12 | static auto GetVFtableFun(int) -> uintptr_t*; 13 | static auto GetVFtables() -> uintptr_t**; 14 | static auto SetVFtables(uintptr_t** vTables) -> void; 15 | 16 | public: 17 | static uintptr_t* startLeaveGameCall; 18 | //static uintptr_t* forEachPlayerCall; 19 | static uintptr_t* tickCall; 20 | public: 21 | auto getAllPlayer()->std::vector; 22 | public: 23 | //虚表函数 24 | auto getTime()->int; /*112*/ 25 | auto setTime(int)->void; /*113*/ 26 | auto getSeed() -> unsigned int; /*114*/ 27 | 28 | //虚表函数Hook 29 | auto startLeaveGame() -> void; /*2*/ 30 | auto Tick()->void*; /*101*/ 31 | // 虚表函数 32 | auto forEachPlayer(std::function) -> void; /*207-208 /-562(不对)- 用特征码定位call非虚表 */ 33 | auto isClientSide() -> bool; /*291*/ // 1.20.15 34 | auto setSimPaused(bool) -> void; /*322*/ // 1.20.15 35 | auto getSimPaused() -> bool; /*323*/ // 1.20.15 36 | }; -------------------------------------------------------------------------------- /SDK/LocalPlayer.cpp: -------------------------------------------------------------------------------- 1 | #include "LocalPlayer.h" 2 | #include "ClientInstance.h" 3 | 4 | uintptr_t** LocalPlayer::vfTables = nullptr; 5 | int LocalPlayer::toCIoffset = 0; 6 | int LocalPlayer::onGroundoffset = 0; 7 | 8 | uintptr_t* LocalPlayer::tickWorldCall = nullptr; 9 | 10 | template 11 | auto LocalPlayer::GetVFtableFun(int a)->auto* { 12 | return reinterpret_cast(vfTables[a]); 13 | } 14 | 15 | auto LocalPlayer::GetVFtableFun(int a)->uintptr_t* { 16 | return vfTables[a]; 17 | } 18 | 19 | auto LocalPlayer::GetVFtables()->uintptr_t** { 20 | return vfTables; 21 | } 22 | 23 | auto LocalPlayer::SetVFtables(uintptr_t** vfTable)->void { 24 | vfTables = vfTable; 25 | } 26 | 27 | //定义函数 28 | auto LocalPlayer::getClientInstance()->ClientInstance* { 29 | return *((ClientInstance**)((uintptr_t)this + toCIoffset)); //这个偏移是偏移字节 30 | } 31 | 32 | // 废弃 33 | auto LocalPlayer::isOnGround()->bool* { 34 | return (bool*)((uintptr_t)this + onGroundoffset); 35 | } 36 | 37 | 38 | //搜索 ) = -1028390912; 找所在函数 参数只有两个的那个函数即是目标函数 39 | auto LocalPlayer::LocalPlayerTurn(vec2_t* viewAngles)->void{ 40 | //A3C640 41 | static SignCode sign("LocalPlayer::LocalPlayerTurn"); 42 | sign << "48 8B C4 48 89 58 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 ? 0F 29 78 ? 44 0F 29 40 ? 44 0F 29 48 ? 44 0F 29 90 ? ? ? ? 44 0F 29 98 ? ? ? ? 44 0F 29 A0 ? ? ? ? 44 0F 29 A8 ? ? ? ? 44 0F 29 B0 ? ? ? ? 44 0F 29 B8 ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 48 8B DA"; 43 | sign.AddSignCall("E8 ? ? ? ? 48 8B 07 0F 28 CE"); 44 | sign.AddSignCall("E8 ? ? ? ? 48 8B 07 0F 28 CF"); 45 | _ASSERT(sign); 46 | using Turn = void(__thiscall*)(LocalPlayer*, vec2_t*); 47 | reinterpret_cast(*sign)(this, viewAngles); 48 | } 49 | 50 | //虚表函数 51 | 52 | //auto LocalPlayer::setPos(vec3_t* pos)->__int64 { 53 | // return GetVFtableFun<__int64, LocalPlayer*, vec3_t*>(13)(this,pos); //19? 54 | //} 55 | 56 | //无法验证虚表 57 | //auto LocalPlayer::jumpFromGround()->void* { 58 | // return GetVFtableFun(346)(this); 59 | //} 60 | 61 | //无法验证虚表 62 | //auto LocalPlayer::displayClientMessage(std::mcstring* text)->void* { 63 | // return GetVFtableFun(389)(this, text); 64 | //} -------------------------------------------------------------------------------- /SDK/LocalPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Player.h" 3 | //#include 4 | 5 | //LocalPlayer::LocalPlayer 6 | //40 55 53 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 89 4D ? 4C 89 45 ? 48 8B DA 7 | 8 | class LocalPlayer : public Player { 9 | protected: 10 | static uintptr_t** vfTables; 11 | 12 | public: 13 | static int toCIoffset; 14 | static int onGroundoffset; 15 | 16 | public: 17 | template 18 | static auto GetVFtableFun(int)->auto*; 19 | static auto GetVFtableFun(int)->uintptr_t*; 20 | static auto GetVFtables()->uintptr_t**; 21 | static auto SetVFtables(uintptr_t** vTables)->void; 22 | //LocalPlayer::displayClientMessage(std::string const&) //388 23 | 24 | // Hook函数回调 25 | public: 26 | static uintptr_t* tickWorldCall; /*332*/ 27 | 28 | public: 29 | //定义函数 30 | auto getClientInstance()->class ClientInstance*; 31 | auto isOnGround()->bool*; 32 | //auto isValid()->bool; 33 | 34 | 35 | // 函数 36 | 37 | /** 38 | * @brief 设置玩家视角朝向 39 | * @param viewAngles 朝向 40 | * @return 41 | */ 42 | auto LocalPlayerTurn(vec2_t* viewAngles) -> void; 43 | public: 44 | //虚表函数 45 | //auto setPos(vec3_t*)->__int64; /*14*/ 46 | //auto jumpFromGround()-> void*; /*346*/ 47 | //auto displayClientMessage(std::mcstring*)-> void*; /*389*/ 48 | }; -------------------------------------------------------------------------------- /SDK/LoopbackPacketSender.cpp: -------------------------------------------------------------------------------- 1 | #include "LoopbackPacketSender.h" 2 | 3 | uintptr_t** LoopbackPacketSender::vfTables = nullptr; 4 | 5 | 6 | template 7 | auto LoopbackPacketSender::GetVFtableFun(int a)->auto* { 8 | return reinterpret_cast(vfTables[a]); 9 | } 10 | 11 | auto LoopbackPacketSender::GetVFtableFun(int a)->uintptr_t* { 12 | return vfTables[a]; 13 | } 14 | 15 | auto LoopbackPacketSender::GetVFtables()->uintptr_t** { 16 | return vfTables; 17 | } 18 | 19 | auto LoopbackPacketSender::SetVFtables(uintptr_t** vfTable)->void { 20 | vfTables = vfTable; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /SDK/LoopbackPacketSender.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class LoopbackPacketSender { 6 | //private: 7 | // virtual ~LoopbackPacketSender() = 0; 8 | //public: 9 | // virtual void __cdecl send(class Packet&) = 0; 10 | // //__int64 __fastcall sub_141F53910(__int64 a1, _BYTE *a2, __int64 a3) 11 | // virtual void* __cdecl sendToServer(class Packet&) = 0; 12 | // virtual void __cdecl sendToClient(class NetworkIdentifier const&, class Packet const&, enum SubClientId) = 0; 13 | // virtual void __cdecl sendToClient(class UserEntityIdentifierComponent const*, class Packet const&) = 0; 14 | // virtual void __cdecl sendToClients(class std::vector > const&, class Packet const&) = 0; 15 | // virtual void __cdecl sendBroadcast(class NetworkIdentifier const&, enum SubClientId, class Packet const&) = 0; 16 | // virtual void __cdecl sendBroadcast(class Packet const&) = 0; 17 | // virtual void __cdecl flush(class NetworkIdentifier const&, class std::function&&) = 0; 18 | 19 | protected: 20 | static uintptr_t** vfTables; 21 | public: 22 | template 23 | static auto GetVFtableFun(int) -> auto*; 24 | static auto GetVFtableFun(int) -> uintptr_t*; 25 | static auto GetVFtables() -> uintptr_t**; 26 | static auto SetVFtables(uintptr_t** vTables) -> void; 27 | 28 | 29 | }; -------------------------------------------------------------------------------- /SDK/MinecraftUIRenderContext.cpp: -------------------------------------------------------------------------------- 1 | #include "MinecraftUIRenderContext.h" 2 | #include "..\Mod\Utils\HMath.h" 3 | 4 | 5 | uintptr_t* MinecraftUIRenderContext::drawtextCall = nullptr; 6 | 7 | auto MinecraftUIRenderContext::Fillshape(vec2_t pos, vec2_t size, UIColor color)->void { 8 | RectangleArea ra = RectangleArea(pos.x, pos.x + size.x, pos.y, pos.y + size.y); 9 | this->fillRectangle(ra, color, color.a); 10 | } 11 | 12 | auto MinecraftUIRenderContext::Drawshape(vec2_t pos, vec2_t size, UIColor color, float w)->void { 13 | RectangleArea ra = RectangleArea(pos.x, pos.x + size.x, pos.y, pos.y + size.y); 14 | this->drawRectangle(ra, color, color.a, static_cast(w)); 15 | } -------------------------------------------------------------------------------- /SDK/MinecraftUIRenderContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "..\Mod\Utils\HMath.h" 4 | #include "..\Mod\Utils\Game.h" 5 | #include "ClientInstance.h" 6 | 7 | 8 | /* 如何虚函数出错,就是去ida跑安卓的MC去对新的虚函数 */ 9 | /* 按照视频作者的说法,这个虚函数从一开始就没有变过 */ 10 | 11 | struct RectangleArea { 12 | public: 13 | float w, x, y, z; 14 | 15 | RectangleArea(float w, float x, float y, float z) { 16 | this->w = w; 17 | this->x = x; 18 | this->y = y; 19 | this->z = z; 20 | } 21 | }; 22 | 23 | struct UIColor { 24 | public: 25 | float r, g, b, a; 26 | UIColor(float r = 255, float g = 255, float b = 255, float a = 255) { 27 | this->r = r / 255.f; 28 | this->g = g / 255.f; 29 | this->b = b / 255.f; 30 | this->a = a / 255.f; 31 | } 32 | }; 33 | 34 | struct TextMeasureData { 35 | float textSize; 36 | int idk; 37 | bool displayShadow; 38 | bool bool2; 39 | }; 40 | 41 | class BitmapFont; 42 | class CaretMeasureData { 43 | public: 44 | int a; 45 | int b; 46 | public: 47 | CaretMeasureData(int paramA = 0xFFFFFFFF, bool paramB = false) { 48 | this->a = paramA; 49 | this->b = paramB; 50 | }; 51 | }; 52 | 53 | using MUICDrawText = void(__fastcall*)(class MinecraftUIRenderContext*, BitmapFont*, RectangleArea const&, std::mcstring* , UIColor const&, float, float, TextMeasureData*, CaretMeasureData*); 54 | //MUICDrawText drawtextCall; 55 | 56 | class MinecraftUIRenderContext { 57 | public: 58 | class ClientInstance* CI; 59 | private: 60 | virtual void Destructor(); 61 | public: 62 | virtual float getLinelength(BitmapFont&, std::string const&, float, bool); 63 | private: 64 | virtual int getTextAlpha(); 65 | virtual void setTextAlpha(); 66 | public: 67 | virtual void drawDebugText(RectangleArea const&, std::string*, UIColor const&, float, float, TextMeasureData*, CaretMeasureData*); 68 | virtual void drawText(BitmapFont&, RectangleArea const&, std::string*, UIColor const&, float, float, TextMeasureData*, CaretMeasureData*); 69 | virtual void flushText(float); 70 | private: 71 | virtual void drawImage(); 72 | virtual void drawNineslice(); 73 | virtual void flushImage(); 74 | virtual void beginSharedMeshBatch(); 75 | virtual void endSharedMeshBatch(); 76 | public: 77 | virtual void drawRectangle(RectangleArea const&, UIColor const&, float, int); 78 | virtual void fillRectangle(RectangleArea const&, UIColor const&, float); 79 | 80 | 81 | static uintptr_t* drawtextCall; 82 | 83 | //非官方 自定义函数 84 | public: 85 | 86 | /// 87 | /// 填充矩形 88 | /// 89 | /// 位置 90 | /// 大小 91 | /// 颜色 92 | void Fillshape(struct vec2_t, struct vec2_t, UIColor); 93 | /// 94 | /// 画空心矩形 95 | /// 96 | /// 位置(左上) 97 | /// 大小 98 | /// 颜色 99 | /// 边框宽度 100 | void Drawshape(struct vec2_t pos, struct vec2_t size, UIColor, float w); 101 | 102 | void Drawtext(const vec2_t& pos, std::string* textStr, const UIColor& color, float textSize) { 103 | 104 | CaretMeasureData caretMeasureData{}; 105 | if (!Game::mcfont) 106 | { 107 | return; 108 | } 109 | std::mcstring text(*textStr); 110 | RectangleArea rect(pos.x, pos.x + 1000, pos.y - 1, pos.y + 1000); 111 | 112 | TextMeasureData textMeasure{}; 113 | memset(&textMeasure, 0, sizeof(TextMeasureData)); 114 | textMeasure.textSize = textSize; 115 | 116 | reinterpret_cast(drawtextCall)(this, Game::mcfont, rect, &text, color, color.a, 0, &textMeasure, &caretMeasureData); 117 | } 118 | }; -------------------------------------------------------------------------------- /SDK/Mob.cpp: -------------------------------------------------------------------------------- 1 | #include "Mob.h" 2 | 3 | uintptr_t** Mob::vfTables = nullptr; 4 | 5 | //uintptr_t Mob::setSprintingFunAddr = 0x00; 6 | 7 | template 8 | auto Mob::GetVFtableFun(int a)->auto* { 9 | return reinterpret_cast(vfTables[a]); 10 | } 11 | 12 | auto Mob::GetVFtableFun(int a)->uintptr_t* { 13 | return vfTables[a]; 14 | } 15 | 16 | auto Mob::GetVFtables()->uintptr_t** { 17 | return vfTables; 18 | } 19 | 20 | auto Mob::SetVFtables(uintptr_t** vfTable)->void { 21 | vfTables = vfTable; 22 | } 23 | 24 | 25 | /* 26 | auto Mob::setSprintingEx(bool v)->char { 27 | using FunsetSprinting = char(__fastcall*)(Mob*, bool); 28 | return reinterpret_cast(setSprintingFunAddr)(this,v); 29 | } 30 | */ 31 | 32 | /* 33 | __int64 __fastcall Mob::isSprinting(Mob* this) 34 | { 35 | return (**(__int64(__fastcall***)(Mob*, __int64))this)(this, 3i64); 36 | }*/ 37 | auto Mob::isSprinting()-> bool{ 38 | return getStatusFlag(ActorFlags::isSprinting); 39 | } 40 | 41 | 42 | //虚表函数 43 | // 检查版本 1.20.41 44 | auto Mob::setSprinting(bool v)->void { 45 | GetVFtableFun(175)(this,v); 46 | } 47 | 48 | auto Mob::getSpeed() -> float 49 | { 50 | return GetVFtableFun(178)(this); 51 | } 52 | 53 | auto Mob::setSpeed(float s) -> void 54 | { 55 | GetVFtableFun(179)(this, s); 56 | } 57 | 58 | // 检查版本 1.20.30 59 | //auto Mob::lookAt(Actor* actor,float f1, float f2)->void { 60 | // GetVFtableFun(261)(this, actor,f1,f2); 61 | //} -------------------------------------------------------------------------------- /SDK/Mob.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Actor.h" 3 | 4 | class Mob : public Actor { 5 | protected: 6 | static uintptr_t** vfTables; 7 | public: 8 | template 9 | static auto GetVFtableFun(int)->auto*; 10 | static auto GetVFtableFun(int)->uintptr_t*; 11 | static auto GetVFtables()->uintptr_t**; 12 | static auto SetVFtables(uintptr_t** vTables)->void; 13 | 14 | public: 15 | //static uintptr_t setSprintingFunAddr; 16 | 17 | public: 18 | //即使放在Tick中执行,也不会被HIVE踢 - 这个应该是 Mob::isSprinting 内部中的某个函数 19 | //auto setSprintingEx(bool)->char; 20 | auto isSprinting()->bool; 21 | 22 | //虚表函数 23 | public: 24 | auto setSprinting(bool)->void; /*251*///函数是对的,但在Tick中执行会持续发包(猜测),会被HIVE踢 25 | auto getSpeed() -> float; /*254*/ 26 | auto setSpeed(float s) -> void; /*255*/ 27 | //auto lookAt(Actor*, float, float)->void; /*303*///最后两个参数始终调试不正确 28 | }; -------------------------------------------------------------------------------- /SDK/Packet.cpp: -------------------------------------------------------------------------------- 1 | #include "Packet.h" 2 | #include "Utils.h" 3 | 4 | auto Packet::isValid() -> bool 5 | { 6 | return Utils::CallVFunc<6, bool>(this); 7 | } 8 | -------------------------------------------------------------------------------- /SDK/Packet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mcstring.h" 4 | 5 | class Packet { 6 | public: 7 | virtual ~Packet() = 0; 8 | virtual auto getId() -> int = 0; 9 | virtual auto getName() -> std::mcstring* = 0; 10 | 11 | auto isValid() -> bool; 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /SDK/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | 3 | #include "../Mod/Utils/Utils.h" 4 | 5 | 6 | int Player::RotPtrOffset = 0; 7 | //int Player::Rot2 = 0; 8 | 9 | 10 | uintptr_t** Player::vfTables = nullptr; 11 | 12 | uintptr_t* Player::tickWorldCallptr = nullptr; 13 | uintptr_t* Player::getShadowRadiusCallptr = nullptr; 14 | //uintptr_t* Player::startSwimmingCallptr = nullptr; 15 | 16 | template 17 | auto Player::GetVFtableFun(int a)->auto* { 18 | return reinterpret_cast(vfTables[a]); 19 | } 20 | 21 | auto Player::GetVFtableFun(int a)->uintptr_t* { 22 | return vfTables[a]; 23 | } 24 | 25 | auto Player::GetVFtables()->uintptr_t** { 26 | return vfTables; 27 | } 28 | 29 | auto Player::SetVFtables(uintptr_t** vfTable)->void { 30 | vfTables = vfTable; 31 | } 32 | 33 | //vec.x表示竖直方向的值且竖直方向的值在前 34 | auto Player::getRotEx1()->vec2_t* { 35 | return *(vec2_t**)(this + RotPtrOffset); 36 | } 37 | 38 | auto Player::getRotEx2()->vec2_t* { 39 | return *(vec2_t**)(this + RotPtrOffset) + 1; 40 | } 41 | 42 | auto Player::getFootPos() -> vec3_ti 43 | { 44 | vec3_ti footPos; 45 | auto pos = getPosition(); 46 | if (pos->x < 0) footPos.x = static_cast(pos->x - 1.f); else footPos.x = static_cast(pos->x); 47 | if (pos->y < 0) footPos.y = static_cast(pos->y - 1.f); else footPos.y = static_cast(pos->y); 48 | if (pos->z < 0) footPos.z = static_cast(pos->z - 1.f); else footPos.z = static_cast(pos->z); 49 | 50 | footPos.y -= 1; 51 | return footPos; 52 | } 53 | 54 | auto Player::getFootBlockPos() -> vec3_ti 55 | { 56 | vec3_ti footBlockPos; 57 | auto pos = getPosition(); 58 | if (pos->x < 0) footBlockPos.x = static_cast(pos->x - 1.f); else footBlockPos.x = static_cast(pos->x); 59 | if (pos->y < 0) footBlockPos.y = static_cast(pos->y - 1.f); else footBlockPos.y = static_cast(pos->y); 60 | if (pos->z < 0) footBlockPos.z = static_cast(pos->z - 1.f); else footBlockPos.z = static_cast(pos->z); 61 | 62 | footBlockPos.y -= 2; 63 | return footBlockPos; 64 | } 65 | 66 | 67 | 68 | // 函数的定位可以通过搜索关键字(a1, 218128893);找到 69 | auto Player::getAbilitiesComponent() -> void* 70 | { 71 | // 首先获取:entt::basic_registry>::try_get 函数 72 | const char* memcode_fn = "40 53 48 83 EC ? 48 8B DA BA FD 61"; 73 | const char* memcode_call = "E8 ? ? ? ? 48 85 ? 74 ? 48 8B 5C 24 ? 48 83 C4 ? 5F C3"; 74 | static uintptr_t call = Utils::getFunFromSigAndCall(memcode_fn, memcode_call, 1); 75 | _ASSERT(call); 76 | return reinterpret_cast(call)(**(uintptr_t**)((uintptr_t)this + 8), (uintptr_t)this + 16); 77 | } 78 | 79 | auto Player::isFlying() -> bool 80 | { 81 | const char* memcode_call = "E8 ? ? ? ? 84 C0 75 ? F3 0F 59 F7"; 82 | const char* memcode_fn = "48 83 EC ? 48 8B 41 ? 48 8B D1 48 8B 08 8B 42 ? 48 8D 54 24 ? 89 44 24 ? E8 ? ? ? ? 48 85 C0 74 ? 48 8D 88 ? ? ? ? 48 83 C0 ? 48 3B C8 74 ? 48 83"; 83 | static uintptr_t call = Utils::getFunFromSigAndCall(memcode_fn, memcode_call, 1); 84 | _ASSERT(call); 85 | return reinterpret_cast(call)(this); 86 | } 87 | 88 | auto Player::setFlying(bool isfly) -> void 89 | { 90 | uintptr_t comp = (uintptr_t)getAbilitiesComponent(); 91 | // 0xA canFly 9 flying 92 | char* result = (char*)(comp + 4 * (3i64 * (char)9u + 58)); 93 | if (*result == 1) 94 | { 95 | *result = 2; 96 | result[4] = 0; 97 | } 98 | result[4] = isfly; 99 | } 100 | 101 | auto Player::setCanFlyEx(bool canfly) -> void 102 | { 103 | uintptr_t comp = (uintptr_t)getAbilitiesComponent(); 104 | // 0xA canFly 9 flying 105 | char* result = (char*)(comp + 4 * (3i64 * (char)0xAu + 58)); 106 | if (*result == 1) 107 | { 108 | *result = 2; 109 | result[4] = 0; 110 | } 111 | result[4] = canfly; 112 | } 113 | 114 | 115 | //虚表函数 116 | // 检查版本 1.20.41 117 | auto Player::teleportTo(vec3_t* pos, bool a1, unsigned int a2, unsigned int a3)->void { 118 | GetVFtableFun(26)(this,pos,a1,a2,a3); 119 | } 120 | 121 | // 检查版本 1.20.30 122 | auto Player::getSelectedItem()->ItemStack* 123 | { 124 | return GetVFtableFun(94)(this); 125 | } 126 | 127 | auto Player::getSpeed() -> float 128 | { 129 | return GetVFtableFun(178)(this); 130 | } 131 | 132 | auto Player::setSpeed(float s) -> void 133 | { 134 | return GetVFtableFun(179)(this, s); 135 | } 136 | 137 | auto Player::setPlayerGameType(int GameType) -> void 138 | { 139 | GetVFtableFun(253)(this, GameType); 140 | } 141 | 142 | auto Player::getXuid() ->std::mcstring 143 | { 144 | std::mcstring* ret = GetVFtableFun(274)(this); 145 | return *ret; 146 | } 147 | 148 | auto Player::getShadowRadius() -> float 149 | { 150 | using Fn = float(__fastcall*)(Player*); 151 | return reinterpret_cast(getShadowRadiusCallptr)(this); 152 | } 153 | 154 | auto Player::tickWorld(Tick* tick) -> void 155 | { 156 | using Fn = void(__fastcall*)(Player*, class Tick*); 157 | reinterpret_cast(tickWorldCallptr)(this, tick); 158 | } 159 | -------------------------------------------------------------------------------- /SDK/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\Mod\Utils\HMath.h" 3 | #include "Actor.h" 4 | #include "Mob.h" 5 | 6 | 7 | class Player : public Mob 8 | { 9 | protected: 10 | static uintptr_t** vfTables; 11 | 12 | public: 13 | static uintptr_t* tickWorldCallptr; 14 | static uintptr_t* getShadowRadiusCallptr; 15 | //static uintptr_t* startSwimmingCallptr; 16 | public: 17 | template 18 | static auto GetVFtableFun(int)->auto*; 19 | static auto GetVFtableFun(int)->uintptr_t*; 20 | static auto GetVFtables()->uintptr_t**; 21 | static auto SetVFtables(uintptr_t** vTables)->void; 22 | 23 | public: 24 | 25 | static int RotPtrOffset; //偏移指向 vec2_t 指针 26 | //static int Rot2; //偏移指向 vec2_t 指针 27 | 28 | public: 29 | //ret->x 表示竖直方向的值 30 | auto getRotEx1()->vec2_t*; 31 | //ret->x 表示竖直方向的值 32 | auto getRotEx2()->vec2_t*; 33 | 34 | auto getFootPos() -> vec3_ti; 35 | auto getFootBlockPos() -> vec3_ti; 36 | 37 | auto getAbilitiesComponent() -> void*; 38 | auto isFlying() -> bool; 39 | auto setFlying(bool) -> void; 40 | auto setCanFlyEx(bool) -> void; 41 | 42 | public: 43 | //虚表函数 44 | //44 45 | auto teleportTo(vec3_t*, bool, unsigned int, unsigned int)->void; 46 | //auto displayChatMessage(std::mcstring*)->__int64; 47 | auto getSelectedItem() -> class ItemStack*; /*164*/ 48 | 49 | auto getSpeed() -> float; /*254*/ 50 | auto setSpeed(float s) -> void; /*255*/ 51 | auto setPlayerGameType(int GameType) -> void; /*368*/ 52 | auto getXuid() -> std::mcstring; /*396*/ 53 | 54 | //Hook虚表函数 55 | auto getShadowRadius()->float; /*79*/ 56 | //auto startSwimming()->void; /*202*/ 57 | 58 | auto tickWorld(class Tick*) -> void; /*371*/ 59 | }; -------------------------------------------------------------------------------- /SDK/RemotePlayer.cpp: -------------------------------------------------------------------------------- 1 | #include "RemotePlayer.h" 2 | 3 | uintptr_t** RemotePlayer::vfTables = nullptr; 4 | 5 | uintptr_t* RemotePlayer::tickWorldCallptr = nullptr; 6 | 7 | template 8 | auto RemotePlayer::GetVFtableFun(int a)->auto* { 9 | return reinterpret_cast(vfTables[a]); 10 | } 11 | 12 | auto RemotePlayer::GetVFtableFun(int a)->uintptr_t* { 13 | return vfTables[a]; 14 | } 15 | 16 | auto RemotePlayer::GetVFtables()->uintptr_t** { 17 | return vfTables; 18 | } 19 | 20 | auto RemotePlayer::SetVFtables(uintptr_t** vfTable)->void { 21 | vfTables = vfTable; 22 | } 23 | 24 | auto RemotePlayer::tickWorld()->void* 25 | { 26 | using Fn = void*(__fastcall*)(RemotePlayer*); 27 | return reinterpret_cast(tickWorldCallptr)(this); 28 | } 29 | -------------------------------------------------------------------------------- /SDK/RemotePlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Player.h" 3 | 4 | class RemotePlayer : public Player { // 好像是继承自LocalPlayer 5 | protected: 6 | static uintptr_t** vfTables; 7 | 8 | public: 9 | static uintptr_t* tickWorldCallptr; 10 | public: 11 | template 12 | static auto GetVFtableFun(int) -> auto*; 13 | static auto GetVFtableFun(int) -> uintptr_t*; 14 | static auto GetVFtables() -> uintptr_t**; 15 | static auto SetVFtables(uintptr_t** vTables) -> void; 16 | 17 | public: 18 | //Hook 虚表函数 19 | auto tickWorld()->void*; 20 | }; -------------------------------------------------------------------------------- /SDK/ServerPlayer.cpp: -------------------------------------------------------------------------------- 1 | #include "../Mod/Utils/Utils.h" 2 | #include "ServerPlayer.h" 3 | #include "LocalPlayer.h" 4 | 5 | uintptr_t** ServerPlayer::vfTables = nullptr; 6 | 7 | template 8 | auto ServerPlayer::GetVFtableFun(int a)->auto* { 9 | return reinterpret_cast(vfTables[a]); 10 | } 11 | 12 | auto ServerPlayer::GetVFtableFun(int a)->uintptr_t* { 13 | return vfTables[a]; 14 | } 15 | 16 | auto ServerPlayer::GetVFtables()->uintptr_t** { 17 | return vfTables; 18 | } 19 | 20 | auto ServerPlayer::SetVFtables(uintptr_t** vfTable)->void { 21 | vfTables = vfTable; 22 | } 23 | 24 | 25 | //虚函数 回调 26 | uintptr_t* ServerPlayer::tickWorldCall = nullptr; 27 | 28 | 29 | //虚函数 30 | //具有原始功能的调用 31 | auto ServerPlayer::tickWorld(void* Tick)->void* { 32 | using Fn = void*(__fastcall*)(ServerPlayer*, void*); 33 | return reinterpret_cast(tickWorldCall)(this, Tick); 34 | } -------------------------------------------------------------------------------- /SDK/ServerPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Player.h" 3 | 4 | class ServerPlayer : public Player 5 | { 6 | protected: 7 | static uintptr_t** vfTables; 8 | public: 9 | template 10 | static auto GetVFtableFun(int)->auto*; 11 | static auto GetVFtableFun(int)->uintptr_t*; 12 | static auto GetVFtables()->uintptr_t**; 13 | static auto SetVFtables(uintptr_t** vTables)->void; 14 | 15 | //虚函数 16 | public: 17 | static uintptr_t* tickWorldCall; /*332*/ 18 | auto tickWorld(void* Tick)->void*; 19 | }; 20 | -------------------------------------------------------------------------------- /SDK/mcstring.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace std 5 | { 6 | class mcstring { 7 | public: 8 | union { 9 | char text[16]; //0x0000 10 | char* pText = nullptr; //0x0000 11 | }; 12 | 13 | size_t textLength; //0x0010 14 | size_t alignedTextLength; //0x0018 15 | 16 | mcstring() { 17 | memset(this, 0, sizeof(mcstring)); 18 | } 19 | 20 | mcstring(mcstring const& copy) { 21 | memset(this, 0, sizeof(mcstring)); 22 | textLength = copy.textLength; 23 | alignedTextLength = copy.alignedTextLength; 24 | if (copy.textLength < 16) 25 | memcpy(text, copy.text, 16); 26 | else { 27 | size_t size = textLength + 1; 28 | 29 | if (size + 1 >= 0x1000) 30 | size += 8; 31 | 32 | pText = reinterpret_cast(malloc(size + 1)); 33 | alignedTextLength = size; 34 | if (pText != 0x0 && size + 1 >= 0x1000) { 35 | *reinterpret_cast(pText) = pText; 36 | pText += 8; 37 | } 38 | 39 | if (pText != 0x0 && copy.pText != 0x0) { 40 | memcpy(pText, copy.pText, size); 41 | pText[size] = 0; 42 | } 43 | } 44 | } 45 | 46 | mcstring& operator=(mcstring const& copy) { 47 | release(); 48 | memset(this, 0, sizeof(mcstring)); 49 | textLength = copy.textLength; 50 | alignedTextLength = copy.alignedTextLength; 51 | if (copy.textLength < 16) 52 | memcpy(text, copy.text, 16); 53 | else { 54 | size_t size = textLength + 1; 55 | 56 | if (size + 1 >= 0x1000) 57 | size += 8; 58 | 59 | pText = reinterpret_cast(malloc(size + 1)); 60 | alignedTextLength = size; 61 | if (pText != 0x0 && size + 1 >= 0x1000) { 62 | *reinterpret_cast(pText) = pText; 63 | pText += 8; 64 | } 65 | 66 | if (pText != 0x0 && copy.pText != 0x0) { 67 | memcpy(pText, copy.pText, textLength); 68 | pText[textLength] = 0; 69 | } 70 | } 71 | return *this; 72 | } 73 | 74 | bool operator==(mcstring const& copy) { 75 | if (alignedTextLength != copy.alignedTextLength) 76 | return false; 77 | if (alignedTextLength < 16) { 78 | return std::string(this->data()) == std::string(copy.text); 79 | } 80 | else { 81 | return std::string(this->data()) == std::string(copy.pText); 82 | } 83 | } 84 | 85 | mcstring(std::string str) { 86 | memset(this, 0, sizeof(mcstring)); 87 | textLength = str.size(); 88 | alignedTextLength = textLength | 0xF; 89 | if (str.size() < 16) { 90 | memcpy(text, str.c_str(), str.size()); 91 | if (str.size() < 15) 92 | text[str.size()] = 0; 93 | } 94 | else { 95 | size_t size = str.size(); 96 | if (size + 1 >= 0x1000) 97 | size += 8; 98 | 99 | pText = reinterpret_cast(malloc(size + 1)); 100 | alignedTextLength = size; 101 | if (pText != 0x0 && size + 1 >= 0x1000) { 102 | *reinterpret_cast(pText) = pText; 103 | pText += 8; 104 | } 105 | 106 | if (pText != 0x0) { 107 | memcpy(pText, str.c_str(), str.size()); 108 | pText[str.size()] = 0; 109 | } 110 | } 111 | } 112 | 113 | mcstring(void* ptr, size_t sizeOfData) { 114 | memset(this, 0, sizeof(mcstring)); 115 | textLength = sizeOfData; 116 | alignedTextLength = sizeOfData; 117 | if (alignedTextLength < 16) 118 | memcpy(text, ptr, sizeOfData); 119 | else 120 | pText = reinterpret_cast(ptr); 121 | } 122 | 123 | void release() { 124 | if (alignedTextLength >= 16 && pText != nullptr) { 125 | if (alignedTextLength + 1 >= 0x1000) { 126 | pText = *reinterpret_cast(reinterpret_cast<__int64>(pText) - 8); 127 | } 128 | free(pText); 129 | } 130 | } 131 | 132 | ~mcstring() { 133 | this->release(); 134 | } 135 | 136 | char* data() { 137 | if (alignedTextLength < 16) { 138 | return this->text; 139 | } 140 | else { 141 | if (this->pText == nullptr) { 142 | return {}; 143 | } 144 | return this->pText; 145 | } 146 | } 147 | 148 | const char* c_str() const { 149 | if (alignedTextLength < 16) { 150 | return this->text; 151 | } 152 | else { 153 | if (this->pText == nullptr) { 154 | return {}; 155 | } 156 | return this->pText; 157 | } 158 | } 159 | 160 | size_t size() { 161 | return textLength; 162 | } 163 | 164 | void setText(std::string str) { 165 | this->release(); 166 | memset(this, 0, sizeof(mcstring)); 167 | textLength = str.size(); 168 | alignedTextLength = textLength | 0xF; 169 | if (str.size() < 16) { 170 | memcpy(text, str.c_str(), str.size()); 171 | if (str.size() < 15) 172 | text[str.size()] = 0; 173 | } 174 | else { 175 | size_t size = str.size(); 176 | if (size + 1 >= 0x1000) 177 | size += 8; 178 | 179 | pText = reinterpret_cast(malloc(size + 1)); 180 | alignedTextLength = size; 181 | if (pText != 0x0 && size + 1 >= 0x1000) { 182 | *reinterpret_cast(pText) = pText; 183 | pText += 8; 184 | } 185 | 186 | if (pText != 0x0) { 187 | memcpy(pText, str.c_str(), str.size()); 188 | pText[str.size()] = 0; 189 | } 190 | } 191 | } 192 | 193 | /** 194 | * @brief 重置但不删除 195 | */ 196 | void resetWithoutDelete() { 197 | *data() = 0; 198 | textLength = 0; 199 | } 200 | 201 | string to_string() const{ 202 | return string(c_str()); 203 | } 204 | }; 205 | } -------------------------------------------------------------------------------- /SDK/sdk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PRIORITY_USE_VTF 1 4 | -------------------------------------------------------------------------------- /minhook/libMinHook.x64-v143-md.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cngege/Mod/bb1c3ae96d33438e9d6a544a3b9855e86cb21284/minhook/libMinHook.x64-v143-md.lib -------------------------------------------------------------------------------- /minhook/libMinHook.x64-v143-mdd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cngege/Mod/bb1c3ae96d33438e9d6a544a3b9855e86cb21284/minhook/libMinHook.x64-v143-mdd.lib --------------------------------------------------------------------------------