├── README.md ├── mhyprotPOC.sln └── mhyprotPOC ├── ApexLegends.cpp ├── ApexLegends.h ├── ApexPrediction.h ├── CFG.cpp ├── CFG.h ├── KeStructs.h ├── LunewareApex.aps ├── LunewareApex.rc ├── Maths.cpp ├── Maths.h ├── Memory.h ├── Overlay.cpp ├── Overlay.h ├── Singleton.h ├── Structs.h ├── Threads.cpp ├── Threads.h ├── Utilities.cpp ├── Utilities.h ├── XorStr.h ├── fonts ├── Century_Gothic.ttf └── kalra.ttf ├── imgui.ini ├── imgui ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_impl_dx10.cpp ├── imgui_impl_dx10.h ├── imgui_impl_dx11.cpp ├── imgui_impl_dx11.h ├── imgui_impl_dx12.cpp ├── imgui_impl_dx12.h ├── imgui_impl_dx9.cpp ├── imgui_impl_dx9.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 └── misc │ ├── cpp │ ├── imgui_stdlib.cpp │ └── imgui_stdlib.h │ └── fonts │ ├── Cousine-Regular.ttf │ ├── DroidSans.ttf │ ├── Karla-Regular.ttf │ ├── ProggyClean.ttf │ ├── ProggyTiny.ttf │ ├── Roboto-Medium.ttf │ └── binary_to_compressed_c.cpp ├── mhyprotPOC.cpp ├── mhyprotPOC.vcxproj ├── mhyprotPOC.vcxproj.filters ├── mhyprotPOC.vcxproj.user ├── resource1.h └── vector.h /README.md: -------------------------------------------------------------------------------- 1 | # pubApexCheat 2 | Apex cheat without R/W. can implement your own R/W and it will work fine. will update readme later 3 | 4 | 5 | Aimbot Prediction and imGui draw functions are pasted, maybe some other code may seem pasted. 6 | 7 | Leaking cause its being sold to kids on ePVP and (maybe) other forums. 8 | 9 | I do not want people getting scammed. (i.e, People who know how to code will make their own cheat, they wont buy sources off of p2c sites. So its most likely kids who wont be able to update the cheat/driver r/w because the driver r/w is performed via a library, i know someone who bought the source from the leaker, against my advice, and had issues with the library i wont be making open source, you can probably find alternatives on github though.) 10 | 11 | -------------------------------------------------------------------------------- /mhyprotPOC.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31019.35 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mhyprotPOC", "mhyprotPOC\mhyprotPOC.vcxproj", "{3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Debug|x64.ActiveCfg = Debug|x64 17 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Debug|x64.Build.0 = Debug|x64 18 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Debug|x86.Build.0 = Debug|Win32 20 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Release|x64.ActiveCfg = Release|x64 21 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Release|x64.Build.0 = Release|x64 22 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Release|x86.ActiveCfg = Release|Win32 23 | {3EEB4220-403A-4F4B-B70B-9FEADC8A05AB}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {DF9A90E6-5995-479D-B473-06AFB0551B8F} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /mhyprotPOC/ApexLegends.cpp: -------------------------------------------------------------------------------- 1 | #include "ApexLegends.h" 2 | 3 | 4 | 5 | 6 | char* get_class_name(uint64_t entity_ptr) 7 | { 8 | char out_str[33]; 9 | uint64_t client_networkable_vtable = Memory::ReadProcessMemory(APEXVars.dwProcessId, + (entity_ptr + 8 * 3)); 10 | uint64_t get_client_class = Memory::ReadProcessMemory(APEXVars.dwProcessId, (client_networkable_vtable + 8 * 3)); 11 | uint32_t disp = Memory::ReadProcessMemory(APEXVars.dwProcessId, (get_client_class + 3)); 12 | const uint64_t client_class_ptr = get_client_class + disp + 7; 13 | ClientClass client_class = Memory::ReadProcessMemory(APEXVars.dwProcessId, (client_class_ptr)); 14 | if (Memory::ReadProcessMemory(APEXVars.dwProcessId, client_class.pNetworkName, &out_str, size_t(33))) { 15 | } 16 | return out_str; 17 | } 18 | uintptr_t ApexLegends::GetLocalPlayer() 19 | { 20 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, APEXVars.pBaseAddress + APEXOffsets.dwLocalPLayer); 21 | } 22 | 23 | uintptr_t ApexLegends::GetEntityBase(DWORD dwEntityIndex) 24 | { 25 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, (APEXVars.pBaseAddress + APEXOffsets.dwEntityList) + (dwEntityIndex << 5)); 26 | } 27 | 28 | bool ApexLegends::IsPlayer(uintptr_t pEntityBase) 29 | { 30 | return ( Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.m_iName) == 125780153691248); 31 | } 32 | 33 | bool ApexLegends::IsEnemy(uintptr_t pEntityBase) 34 | { 35 | //return true; 36 | return ( Memory::ReadProcessMemory(APEXVars.dwProcessId, GetLocalPlayer() + APEXOffsets.m_iTeamNum) != Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.m_iTeamNum)); 37 | } 38 | bool ApexLegends::IsAlive(uintptr_t pEntityBase) 39 | { 40 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_LIFE_STATE) == 0; 41 | } 42 | string ApexLegends::GetPlayerName(int EntityID ) 43 | { 44 | EntityID--; 45 | EntityID *= 0x10; 46 | uint64_t name_ptr = 0; 47 | name_ptr = Memory::ReadProcessMemory(APEXVars.dwProcessId,APEXVars.pBaseAddress + APEXOffsets.OFFSET_NAME_LIST + EntityID); 48 | char name[32]; 49 | Memory::ReadProcessMemory(APEXVars.dwProcessId, name_ptr, &name, sizeof(name)); 50 | return string(name); 51 | } 52 | bool ApexLegends::isDowned(uintptr_t pEntityBase) { 53 | 54 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_BLEED_OUT_STATE) > 0; 55 | } 56 | 57 | bool ApexLegends::isEntityAnItem(uintptr_t pEntityBase) { 58 | 59 | char* class_name = get_class_name(pEntityBase); 60 | return strncmp(class_name, "CPropSurvival", 13) == 0; 61 | } 62 | void ApexLegends::EnableItemGlow(uintptr_t pEntityBase) { 63 | 64 | /*Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x262, 16256); 65 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x2dc, 1193322764); 66 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x3c8, 7); 67 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x3d0, 2);*/ 68 | Memory::WriteProcessMemory(APEXVars.dwProcessId,pEntityBase + APEXOffsets.OFFSET_ITEM_GLOW, 1363184265); 69 | } 70 | double ApexLegends::LastVisibleTime(uintptr_t pEntityBase) 71 | { 72 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.m_flVisible); 73 | } 74 | 75 | Vector3 ApexLegends::GetLocalAimPunch() 76 | { 77 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, GetLocalPlayer() + APEXOffsets.OFFSET_AIMPUNCH); 78 | } 79 | Vector3 ApexLegends::GetEntityViewAngle(uintptr_t pEntityBase) 80 | { 81 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_VIEWANGLES); 82 | } 83 | QAngle ApexLegends::GetViewAngle(uintptr_t pEntityBase) 84 | { 85 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_VIEWANGLES); 86 | 87 | } 88 | Vector3 ApexLegends::GetSwayAngle(uintptr_t pEntityBase) 89 | { 90 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_BREATH_ANGLES); 91 | } 92 | QAngle ApexLegends::GetEntitySwayAngle(uintptr_t pEntityBase) 93 | { 94 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_BREATH_ANGLES); 95 | } 96 | Vector3 ApexLegends::GetLocalPosition() 97 | { 98 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, GetLocalPlayer() + APEXOffsets.OFFSET_CAMERAPOS); 99 | } 100 | Vector3 ApexLegends::GetEntityAbsVelocity(uintptr_t pEntityBase) 101 | { 102 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_ABS_VELOCITY); 103 | } 104 | Vector ApexLegends::GetEntityAbsVelo(uintptr_t pEntityBase) 105 | { 106 | return Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_ABS_VELOCITY); 107 | } 108 | Vector3 ApexLegends::GetEntityPosition(uintptr_t pEntityBase) 109 | { 110 | auto pos = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_ORIGIN); 111 | return pos; 112 | } 113 | Vector ApexLegends::GetEntityPos(uintptr_t pEntityBase) 114 | { 115 | auto pos = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_ORIGIN); 116 | return pos; 117 | } 118 | Vector3 GetEntityBasePosition(uintptr_t pEntityBase) 119 | { 120 | auto pos = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_ORIGIN); 121 | return pos; 122 | } 123 | Vector3 ApexLegends::GetEntityBonePosition(uintptr_t pEntityBase, uint32_t dwBoneId) 124 | { 125 | uintptr_t pBone = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_BONES); 126 | matrix3x4_t matBonePosition = Memory::ReadProcessMemory(APEXVars.dwProcessId, pBone + (dwBoneId * 0x30)); 127 | Vector3 vecBoneBosition = { matBonePosition[0][3], matBonePosition[1][3], matBonePosition[2][3] }; 128 | return GetEntityPosition(pEntityBase) + vecBoneBosition; 129 | } 130 | Vector ApexLegends::GetEntityBonePos(uintptr_t pEntityBase, uint32_t dwBoneId) 131 | { 132 | uintptr_t pBone = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_BONES); 133 | 134 | Vector EntityHead = Vector(); 135 | Vector3 BasePosition = GetEntityBasePosition(pEntityBase); 136 | EntityHead.x = Memory::ReadProcessMemory(APEXVars.dwProcessId,(pBone + 0xCC + (dwBoneId * 0x30))) + BasePosition.X; 137 | EntityHead.y = Memory::ReadProcessMemory(APEXVars.dwProcessId, (pBone + 0xDC + (dwBoneId * 0x30))) + BasePosition.Y; 138 | EntityHead.z = Memory::ReadProcessMemory(APEXVars.dwProcessId, (pBone + 0xEC + (dwBoneId * 0x30))) + BasePosition.Z; 139 | return EntityHead; 140 | } 141 | 142 | void ApexLegends::SetViewAngle(Vector3 vecViewAngle) 143 | { 144 | Memory::WriteProcessMemory(APEXVars.dwProcessId, GetLocalPlayer() + APEXOffsets.OFFSET_VIEWANGLES, vecViewAngle); 145 | } 146 | 147 | void ApexLegends::SetViewQAngle(QAngle vecViewAngle) 148 | { 149 | Memory::WriteProcessMemory(APEXVars.dwProcessId, GetLocalPlayer() + APEXOffsets.OFFSET_VIEWANGLES, vecViewAngle); 150 | } 151 | void ApexLegends::GlowESP(uintptr_t pEntityBase) 152 | { 153 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x262, 16256); 154 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x2dc, 1193322764); 155 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x3c8, 7); 156 | Memory::WriteProcessMemory(APEXVars.dwProcessId, pEntityBase + 0x3d0, 2); 157 | } 158 | 159 | 160 | 161 | Vector3 ApexLegends::WorldToScreen(Vector3 from, float targetWidth, float targetHeight) 162 | { 163 | Vector3 to = Vector3(); 164 | 165 | uint64_t viewRenderer = Memory::ReadProcessMemory(APEXVars.dwProcessId,APEXVars.pBaseAddress +APEXOffsets.OFFSET_VIEWRENDER); 166 | uint64_t viewMatriX = Memory::ReadProcessMemory(APEXVars.dwProcessId, viewRenderer + APEXOffsets.OFFSET_MATRIX); 167 | MatrixA m = Memory::ReadProcessMemory(APEXVars.dwProcessId, viewMatriX); 168 | auto m_vMatriX = m.matrix; 169 | 170 | float w = m_vMatriX[12] * from.X + m_vMatriX[13] * from.Y + m_vMatriX[14] * from.Z + m_vMatriX[15]; 171 | 172 | if (w < 0.01f) return Vector3(); 173 | 174 | to.X = m_vMatriX[0] * from.X + m_vMatriX[1] * from.Y + m_vMatriX[2] * from.Z + m_vMatriX[3]; 175 | to.Y = m_vMatriX[4] * from.X + m_vMatriX[5] * from.Y + m_vMatriX[6] * from.Z + m_vMatriX[7]; 176 | 177 | float invw = 1.0f / w; 178 | to.X *= invw; 179 | to.Y *= invw; 180 | 181 | float X = targetWidth / 2; 182 | float Y = targetHeight / 2; 183 | 184 | X += 0.5f * to.X * targetWidth + 0.5f; 185 | Y -= 0.5f * to.Y * targetHeight + 0.5f; 186 | 187 | to.X = X; 188 | to.Y = Y; 189 | to.Z = 0; 190 | return to; 191 | } 192 | 193 | bool ApexLegends::W2S(Vector from, float* m_vMatrix, int targetWidth, int targetHeight, Vector& to) 194 | { 195 | float w = m_vMatrix[12] * from.x + m_vMatrix[13] * from.y + m_vMatrix[14] * from.z + m_vMatrix[15]; 196 | 197 | if (w < 0.01f) return false; 198 | 199 | to.x = m_vMatrix[0] * from.x + m_vMatrix[1] * from.y + m_vMatrix[2] * from.z + m_vMatrix[3]; 200 | to.y = m_vMatrix[4] * from.x + m_vMatrix[5] * from.y + m_vMatrix[6] * from.z + m_vMatrix[7]; 201 | 202 | float invw = 1.0f / w; 203 | to.x *= invw; 204 | to.y *= invw; 205 | 206 | float x = targetWidth / 2; 207 | float y = targetHeight / 2; 208 | 209 | x += 0.5 * to.x * targetWidth + 0.5; 210 | y -= 0.5 * to.y * targetHeight + 0.5; 211 | 212 | to.x = x; 213 | to.y = y; 214 | to.z = 0; 215 | return true; 216 | } -------------------------------------------------------------------------------- /mhyprotPOC/ApexLegends.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef APEXLEGENDS_H 3 | 4 | #include 5 | #include 6 | #include "Structs.h" 7 | #include "Utilities.h" 8 | #include "Singleton.h" 9 | #include "vector.h" 10 | #include "Memory.h" 11 | 12 | enum BoneIDs { 13 | Head = 8, 14 | Neck = 7, 15 | UpperChest = 5, 16 | Chest =3, 17 | Stomach =2, 18 | }; 19 | 20 | inline namespace ApexLegends 21 | { 22 | struct MatrixA 23 | { 24 | float matrix[16]; 25 | }; 26 | struct ClientClass { 27 | uint64_t pCreateFn; 28 | uint64_t pCreateEventFn; 29 | uint64_t pNetworkName; 30 | uint64_t pRecvTable; 31 | uint64_t pNext; 32 | uint32_t ClassID; 33 | uint32_t ClassSize; 34 | }; 35 | class Variables : public Singleton 36 | { 37 | public: 38 | const char* chProcessName = "r5apex.exe"; 39 | const wchar_t* wcProcessName = L"r5apex.exe"; 40 | DWORD dwProcessId; 41 | //VMMDLL_MAP_MODULEENTRY modApex; 42 | uintptr_t pBaseAddress; 43 | double visiblePlayerInfo[61] = { }; 44 | float EntityFov[61]; 45 | bool Visible[61]; 46 | string PlayerNames[61]; 47 | int PlayersHealth[61]; 48 | int PlayersArmor[61]; 49 | int MaxPlayerArmor[61]; 50 | int localid = 0; 51 | string localname; 52 | }; 53 | 54 | #define APEXVars ApexLegends::Variables::Get() 55 | 56 | class Offsets : public Singleton 57 | { 58 | public: 59 | DWORD ENTITY_SIZE_DEF = 0x42E0; 60 | DWORD dwLocalPLayer = 0x1cc0ce8; 61 | DWORD dwEntityList = 0x1911448; 62 | DWORD m_iTeamNum = 0x448; 63 | DWORD m_iHealth = 0x438; 64 | DWORD m_iName = 0x589; 65 | DWORD m_iSignifierName = 0x0580; 66 | DWORD m_flVisible = 0x1ACC; 67 | DWORD m_shotCount = 0x181c; 68 | DWORD GLOW_ENABLE = 0x350; //Enable //NO 69 | DWORD GLOW_CONTEXT = 0x03C8; //Context //OK 70 | DWORD GLOW_LIFE_TIME = 0x3A4; //Life Time //OK 71 | DWORD GLOW_DISTANCE = 0x3B4; //Distance //OK 72 | DWORD GLOW_TYPE = 0x2C4; //Type //NO 73 | DWORD GLOW_COLOR = 0x1D0; //Color //OK 74 | DWORD GLOW_VISIBLE_TYPE = 0x3D0; //Visible Type 75 | DWORD GLOW_FADE = 0x388; //Fade //NO 76 | DWORD OFFSET_VIEWANGLES = 0x2518; 77 | DWORD OFFSET_ORIGIN = 0x14C; 78 | DWORD OFFSET_BONES = 0xF38; 79 | DWORD OFFSET_AIMPUNCH = 0x2430; 80 | DWORD OFFSET_CAMERAPOS = 0x1ED0; 81 | DWORD OFFSET_ENTITYLIST = 0x18EDA78; // Only Origin 82 | DWORD OFFSET_WEAPON = 0x1a6c;//player + weapon 83 | DWORD OFFSET_BULLET_SPEED = 0x1ED0; 84 | DWORD OFFSET_BULLET_SCALE = 0x1ED8; 85 | DWORD OFFSET_ZOOM_FOV = 0x1678 + 0xb8; //m_playerData + m_curZoomFOV 86 | DWORD OFFSET_ABS_VELOCITY = 0x140; // enemy velocity 87 | DWORD OFFSET_BREATH_ANGLES = (OFFSET_VIEWANGLES - 0x10); 88 | DWORD OFFSET_BLEED_OUT_STATE = 0x26c8; 89 | DWORD OFFSET_ITEM_GLOW = 0x2c0; 90 | DWORD OFFSET_VIEWRENDER = 0x41e3588; 91 | DWORD OFFSET_MATRIX = 0x1b3bd0; 92 | DWORD OFFSET_LIFE_STATE = 0x798; 93 | DWORD OFFSET_NAME_LIST = 0x8382450; 94 | DWORD OFFSET_HEALTH = 0x438; 95 | DWORD OFFSET_SHIELD = 0x170; //m_shieldHealth 96 | DWORD OFFSET_MAX_SHIELD = 0x174; 97 | }; 98 | 99 | #define APEXOffsets ApexLegends::Offsets::Get() 100 | 101 | uintptr_t GetLocalPlayer(); 102 | uintptr_t GetEntityBase(DWORD dwEntityIndex); 103 | bool IsPlayer(uintptr_t pEntityBase); 104 | bool IsEnemy(uintptr_t pEntityBase); 105 | bool isDowned(uintptr_t pEntityBase); 106 | bool isEntityAnItem(uintptr_t pEntityBase); 107 | bool IsAlive(uintptr_t pEntityBase); 108 | void EnableItemGlow(uintptr_t pEntityBase); 109 | double LastVisibleTime(uintptr_t pEntityBase); 110 | string GetPlayerName(int EntityID); 111 | Vector3 GetLocalAimPunch(); 112 | Vector3 GetEntityViewAngle(uintptr_t pEntityBase); 113 | QAngle GetViewAngle(uintptr_t pEntityBase); 114 | Vector3 GetSwayAngle(uintptr_t pEntityBase); 115 | QAngle GetEntitySwayAngle(uintptr_t pEntityBase); 116 | Vector3 GetLocalPosition(); 117 | Vector3 GetEntityAbsVelocity(uintptr_t pEntityBase); 118 | Vector3 GetEntityPosition(uintptr_t pEntityBase); 119 | Vector GetEntityPos(uintptr_t pEntityBase); 120 | Vector GetEntityAbsVelo(uintptr_t pEntityBase); 121 | Vector3 GetEntityBonePosition(uintptr_t pEntityBase, uint32_t dwBoneId); 122 | Vector GetEntityBonePos(uintptr_t pEntityBase, uint32_t dwBoneId); 123 | Vector3 WorldToScreen(Vector3 StartPos, float targetWidth, float targetHeight); 124 | void SetViewAngle(Vector3 vecViewAngle); 125 | void SetViewQAngle(QAngle vecViewAngle); 126 | void GlowESP(uintptr_t pEntityBase); 127 | bool W2S(Vector from, float* m_vMatrix, int targetWidth, int targetHeight, Vector& to); 128 | } 129 | 130 | #endif !APEXLEGENDS_H 131 | -------------------------------------------------------------------------------- /mhyprotPOC/ApexPrediction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct PredictCtx 4 | { 5 | Vector StartPos; 6 | Vector TargetPos; 7 | Vector TargetVel; 8 | float BulletSpeed; 9 | float BulletGravity; 10 | 11 | Vector2D AimAngles; 12 | }; 13 | 14 | Vector ExtrapolatePos(const PredictCtx& Ctx, float Time) 15 | { 16 | return Ctx.TargetPos + (Ctx.TargetVel * Time); 17 | } 18 | 19 | bool OptimalPitch(const PredictCtx& Ctx, const Vector2D& Dir2D, float* OutPitch) 20 | { 21 | float Vel = Ctx.BulletSpeed, Grav = Ctx.BulletGravity, DirX = Dir2D.x, DirY = Dir2D.y; 22 | float Root = Vel * Vel * Vel * Vel - Grav * (Grav * DirX * DirX + 2.f * DirY * Vel * Vel); 23 | if (Root >= 0.f) { *OutPitch = atanf((Vel * Vel - sqrt(Root)) / (Grav * DirX)); return true; } 24 | return false; 25 | } 26 | 27 | bool SolveTrajectory(PredictCtx& Ctx, const Vector& ExtrPos, float* TravelTime) 28 | { 29 | Vector Dir = ExtrPos - Ctx.StartPos; 30 | Vector2D Dir2D = { sqrtf(Dir.x * Dir.x + Dir.y * Dir.y), Dir.z }; 31 | 32 | float CurPitch; 33 | if (!OptimalPitch(Ctx, Dir2D, &CurPitch)) 34 | { 35 | return false; 36 | } 37 | *TravelTime = Dir2D.x / (cosf(CurPitch) * Ctx.BulletSpeed); 38 | Ctx.AimAngles.y = atan2f(Dir.y, Dir.x); 39 | Ctx.AimAngles.x = CurPitch; 40 | return true; 41 | } 42 | 43 | bool BulletPredict(PredictCtx& Ctx) 44 | { 45 | float MAX_TIME = 1.f, TIME_STEP = (1.f / 256.f); 46 | for (float CurrentTime = 0.f; CurrentTime <= MAX_TIME; CurrentTime += TIME_STEP) 47 | { 48 | float TravelTime = 1.f; 49 | Vector ExtrPos = ExtrapolatePos(Ctx, CurrentTime); 50 | if (!SolveTrajectory(Ctx, ExtrPos, &TravelTime)) 51 | { 52 | return false; 53 | } 54 | if (TravelTime < CurrentTime) 55 | { 56 | Ctx.AimAngles = { -RAD2DEG(Ctx.AimAngles.x), RAD2DEG(Ctx.AimAngles.y) }; 57 | return true; 58 | } 59 | } 60 | return false; 61 | } -------------------------------------------------------------------------------- /mhyprotPOC/CFG.cpp: -------------------------------------------------------------------------------- 1 | #include "CFG.h" 2 | #include "Threads.h" 3 | 4 | 5 | void SpeakCFG() 6 | { 7 | printf("\rFoV [%d] ||| Smoothing [%d] ||| Bone Selection = [%s] ||| Maximum Distance = [%d] Visible Check [%d] ", int(CFG.Fov), int(CFG.flSmooth), CFG.BoneName, int(CFG.MaxDistance), CFG.bVischeck); 8 | } 9 | void Configuration::cfg() 10 | { 11 | // Check for uninitialize 12 | if (GetAsyncKeyState(VK_F2)) 13 | CFG.bActive = false; 14 | // VISIBLE CHECK TOGGLE 15 | if (GetAsyncKeyState(VK_XBUTTON2)) 16 | { 17 | CFG.bVischeck = !CFG.bVischeck; 18 | Beep(200, 50); 19 | SpeakCFG();//printf(" \n", bVischeck); 20 | Sleep(100); 21 | 22 | } 23 | if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_RIGHT)) 24 | { 25 | CFG.flSmooth += 1.f; 26 | SpeakCFG(); 27 | Sleep(50); 28 | } 29 | else if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_LEFT)) 30 | { 31 | if (CFG.flSmooth > 7.f) CFG.flSmooth -= 1.f; 32 | SpeakCFG(); 33 | Sleep(50); 34 | } 35 | if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_UP)) 36 | { 37 | CFG.Fov += 1.f; 38 | SpeakCFG(); 39 | Sleep(50); 40 | } 41 | else if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_DOWN)) 42 | { 43 | if (CFG.Fov > 1.f) CFG.Fov -= 1.f; 44 | SpeakCFG(); 45 | Sleep(50); 46 | } 47 | 48 | if (GetAsyncKeyState(VK_F7)) 49 | { 50 | switch (CFG.bone) { 51 | case 8: 52 | CFG.bone = 7; 53 | CFG.BoneName = "neck"; 54 | Beep(2000, 100); 55 | Sleep(130); 56 | break; 57 | case 7: 58 | CFG.bone = 5; 59 | CFG.BoneName = "UpperChest"; 60 | Beep(1500, 100); 61 | Sleep(130); 62 | break; 63 | case 5: 64 | CFG.bone = 3; 65 | CFG.BoneName = "Chest"; 66 | Beep(1000, 100); 67 | Sleep(130); 68 | break; 69 | case 3: 70 | CFG.bone = 2; 71 | CFG.BoneName = "Stomach"; 72 | Beep(500, 100); 73 | Sleep(130); 74 | break; 75 | case 2: 76 | CFG.bone = 8; 77 | CFG.BoneName = "Head"; 78 | Beep(3000, 100); 79 | Sleep(130); 80 | break; 81 | default: 82 | CFG.bone = 7; 83 | CFG.BoneName = "neck (default)"; 84 | Beep(2000, 100); 85 | Sleep(130); 86 | break; 87 | } 88 | SpeakCFG(); 89 | } 90 | if (GetAsyncKeyState(VK_F8)) { 91 | switch (CFG.bone) { 92 | case 2: 93 | CFG.bone = 7; 94 | CFG.BoneName = "neck"; 95 | Beep(2000, 100); 96 | Sleep(130); 97 | break; 98 | case 7: 99 | CFG.bone = 2; 100 | CFG.BoneName = "Stomach"; 101 | Beep(500, 100); 102 | Sleep(130); 103 | break; 104 | default: 105 | CFG.bone = 2; 106 | CFG.BoneName = "Stomach"; 107 | Beep(500, 100); 108 | Sleep(130); 109 | break; 110 | } 111 | SpeakCFG(); 112 | } 113 | if (GetAsyncKeyState(VK_F5)) 114 | { 115 | if (CFG.MaxDistance < 800.f)CFG.MaxDistance += 50.f; 116 | SpeakCFG(); 117 | Sleep(50); 118 | } 119 | else if (GetAsyncKeyState(VK_F6)) 120 | { 121 | if (CFG.MaxDistance > 100.f) CFG.MaxDistance -= 50.f; 122 | SpeakCFG(); 123 | Sleep(50); 124 | } 125 | Sleep(3000); 126 | SpeakCFG(); 127 | } 128 | 129 | 130 | 131 | bool Configuration::FileExists(const char* chDir) 132 | { 133 | return filesystem::exists(chDir); 134 | } 135 | 136 | bool Configuration::WriteToConfigFile() 137 | { 138 | if (!filesystem::exists(CFG.chConfigDirectory)) 139 | { 140 | if (!filesystem::create_directory(CFG.chConfigDirectory)) 141 | { 142 | return false; 143 | } 144 | } 145 | if (filesystem::exists(CFG.chConfigDirectory)) 146 | { 147 | if (!FileExists(CFG.chConfigFile)) 148 | { 149 | std::ofstream ofsOutfile(CFG.chConfigFile); 150 | ofsOutfile << ("KEY=NULL\nMARK=TRUE\nAim_Key=0x6\nAIMBOT=TRUE\nVISCHECK=FALSE\nLEFTAIM=TRUE\nSEMI_AIM=TRUE\nDSMOOTH=TRUE\nBONEID=2\nFoV=30.0\nRSMOOTH=FALSE\nMAXSmooth=60.0\nMINSMOOTH=50.0\nDRAWFOV=FALSE\nRANDBONE=FALSE\nCLOSEBONE=FALSE\nPlGLOW=FALSE\nITGLOW=FALSE\nESP=FALSE\nBSHADOW=FALSE\nBSHDAMT=0.3\nESPNAME=FALSE\nSHNAME=FALSE\nNSHAMT=0.7\nDIST=FALSE\nSHDIST=FALSE\nDSHAMT=0.7\nESPHEALTH=FALSE\nESPARMOR=FALSE\nLINES=FALSE\nLINETYPE=0\nBOXTYPE=0\nINITFROMCFG=FALSE\n"); 151 | ofsOutfile.close(); 152 | return true; 153 | } 154 | else 155 | { 156 | if (ShouldOverwriteCFG()) 157 | { 158 | std::ofstream ofsOutfile(CFG.chConfigFile); 159 | ofsOutfile << ("KEY=NULL\nMARK=TRUE\nAim_Key=0x6\nAIMBOT=TRUE\nVISCHECK=FALSE\nLEFTAIM=TRUE\nSEMI_AIM=TRUE\nDSMOOTH=TRUE\nBONEID=2\nFoV=30.0\nRSMOOTH=FALSE\nMAXSmooth=60.0\nMINSMOOTH=50.0\nDRAWFOV=FALSE\nRANDBONE=FALSE\nCLOSEBONE=FALSE\nPlGLOW=FALSE\nITGLOW=FALSE\nESP=FALSE\nBSHADOW=FALSE\nBSHDAMT=0.3\nESPNAME=FALSE\nSHNAME=FALSE\nNSHAMT=0.7\nDIST=FALSE\nSHDIST=FALSE\nDSHAMT=0.7\nESPHEALTH=FALSE\nESPARMOR=FALSE\nLINES=FALSE\nLINETYPE=0\nBOXTYPE=0\nINITFROMCFG=FALSE\n"); 160 | ofsOutfile.close(); 161 | return true; 162 | } 163 | const char* Watermark = "FALSE"; 164 | const char* Aim = "FALSE"; 165 | const char* Vischeck = "FALSE"; 166 | const char* leftAim = "FALSE"; 167 | const char* Semiaim = "FALSE"; 168 | const char* DynamicSmooth = "FALSE"; 169 | const char* RSMOOTH = "FALSE"; 170 | const char* DRAWFOV = "FALSE"; 171 | const char* RANDBONE = "FALSE"; 172 | const char* CLOSEBONE = "FALSE"; 173 | const char* PlGLOW = "FALSE"; 174 | const char* ITGLOW = "FALSE"; 175 | const char* ESP = "FALSE"; 176 | const char* BSHADOW = "FALSE"; 177 | const char* ESPNAME = "FALSE"; 178 | const char* SHNAME = "FALSE"; 179 | const char* DIST = "FALSE"; 180 | const char* SHDIST = "FALSE"; 181 | const char* ESPHEALTH = "FALSE"; 182 | const char* ESPARMOR = "FALSE"; 183 | const char* LINES = "FALSE"; 184 | const char* AUTOUPDATE = "FALSE"; 185 | const char* SCALENAME = "FALSE"; 186 | const char* SCALEDIST = "FALSE"; 187 | if (CFG.bWatermark) Watermark = "TRUE"; 188 | if (CFG.bAimbot) Aim = "TRUE"; 189 | if (CFG.bVischeck) Vischeck = "TRUE"; 190 | if (CFG.bLeftClickAim) leftAim = "TRUE"; 191 | if (CFG.Safebot) Semiaim = "TRUE"; 192 | if (CFG.DyanamicSmooth) DynamicSmooth = "TRUE"; 193 | if (CFG.RandomizeSmoothness) RSMOOTH = "TRUE"; 194 | if (CFG.DrawFoV) DRAWFOV = "TRUE"; 195 | if (CFG.bRandomBones) RANDBONE = "TRUE"; 196 | if (CFG.bClosestBone) CLOSEBONE = "TRUE"; 197 | if (CFG.bGlowPlayers) PlGLOW = "TRUE"; 198 | if (CFG.bGlowItems) ITGLOW = "TRUE"; 199 | if (CFG.bESP) ESP = "TRUE"; 200 | if (CFG.bDarkenBox) BSHADOW = "TRUE"; 201 | if (CFG.bNames) ESPNAME = "TRUE"; 202 | if (CFG.bDarkenName) SHNAME = "TRUE"; 203 | if (CFG.bDarkenDistance) SHDIST = "TRUE"; 204 | if (CFG.bHealth) ESPHEALTH = "TRUE"; 205 | if (CFG.bArmor) ESPARMOR = "TRUE"; 206 | if (CFG.bLines) LINES = "TRUE"; 207 | if (CFG.bDistance) DIST = "TRUE"; 208 | if (CFG.InitializeFromConfig) AUTOUPDATE = "TRUE"; 209 | if (CFG.bScaleDistance) SCALEDIST = "TRUE"; 210 | if (CFG.bScaleNames) SCALENAME = "TRUE"; 211 | string toWrite=""; 212 | toWrite += string("KEY="); 213 | if (CFG.bSaveKey)toWrite += CFG.strKey + string("\n"); 214 | else toWrite += string("NULL\n"); 215 | toWrite += string("MARK=") + string(Watermark) + string("\n"); 216 | toWrite += string("Aim_Key=") + static_cast(std::stringstream() << "0x" << std::hex << CFG.dwAimKey).str() + string("\n"); 217 | toWrite += string("AIMBOT=") + string(Aim) + string("\n"); 218 | toWrite += string("VISCHECK=") + string(Vischeck) + string("\n"); 219 | toWrite += string("LEFTAIM=") + string(leftAim) + string("\n"); 220 | toWrite += string("SEMI_AIM=") + string(Semiaim) + string("\n"); 221 | toWrite += string("DSMOOTH=") + string(DynamicSmooth) + string("\n"); 222 | toWrite += string("BONEID=") + to_string(CFG.bone) + string("\n"); 223 | 224 | toWrite += string("FoV=") + to_string(CFG.Fov) + string("\n"); 225 | toWrite += string("RSMOOTH=") + string(RSMOOTH) + string("\n"); 226 | toWrite += string("MAXSmooth=") + to_string(CFG.flSmooth) + string("\n"); 227 | toWrite += string("MINSMOOTH=") + to_string(CFG.MinSmooth) + string("\n"); 228 | toWrite += string("DRAWFOV=") + string(DRAWFOV) + string("\n"); 229 | toWrite += string("RANDBONE=") + string(RANDBONE) + string("\n"); 230 | toWrite += string("CLOSEBONE=") + string(CLOSEBONE) + string("\n"); 231 | toWrite += string("PlGLOW=") + string(PlGLOW) + string("\n"); 232 | 233 | toWrite += string("ITGLOW=") + string(ITGLOW) + string("\n"); 234 | toWrite += string("ESP=") + string(ESP) + string("\n"); 235 | toWrite += string("BSHADOW=") + string(BSHADOW) + string("\n"); 236 | toWrite += string("BSHDAMT=") + to_string(CFG.flBoxDark)+ string("\n"); 237 | toWrite += string("ESPNAME=") + string(ESPNAME) + string("\n"); 238 | 239 | toWrite += string("SCALENAME=") + string(SCALENAME) + string("\n"); 240 | toWrite += string("SHNAME=") + string(SHNAME) + string("\n"); 241 | toWrite += string("NSHAMT=") + to_string(CFG.flNameDark) + string("\n"); 242 | toWrite += string("DIST=") + string(DIST) + string("\n"); 243 | toWrite += string("SCALEDIST=") + string(SCALEDIST) + string("\n"); 244 | toWrite += string("SHDIST=") + string(SHDIST) + string("\n"); 245 | toWrite += string("DSHAMT=") + to_string(CFG.flDistDark) + string("\n"); 246 | toWrite += string("ESPHEALTH=") + string(ESPHEALTH) + string("\n"); 247 | toWrite += string("ESPARMOR=") + string(ESPARMOR) + string("\n"); 248 | toWrite += string("LINES=") + string(LINES) + string("\n"); 249 | toWrite += string("LINETYPE=") + to_string(CFG.lineType) + string("\n"); 250 | toWrite += string("BOXTYPE=") + to_string(CFG.dwBoxType) + string("\n"); 251 | toWrite += string("INITFROMCFG=") + string(AUTOUPDATE); 252 | std::ofstream ofsOutfile(CFG.chConfigFile); 253 | ofsOutfile << toWrite; 254 | ofsOutfile.close(); 255 | return true; 256 | 257 | } 258 | 259 | } 260 | } 261 | 262 | bool Configuration::ShouldAutoInitFromFile() 263 | { 264 | string strContent; 265 | ifstream inFile(CFG.chConfigFile); 266 | if (inFile) 267 | { 268 | std::string strContent((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); 269 | const char* tru = "=TRUE"; 270 | for (int i =0; i <= 4; i++) 271 | { 272 | 273 | char charATi = strContent.at(strContent.length() - 1 - i); 274 | if (charATi != tru[4 - i]) 275 | { 276 | //printf("STRcontent AT [%d] [%c]",i,charATi); 277 | //printf("\n"); 278 | //printf("TRUE AT [%d] [%c]", i, tru[4-i]); 279 | //printf("\n"); 280 | return false; 281 | } 282 | } 283 | } 284 | return true; 285 | } 286 | bool Configuration::ShouldOverwriteCFG() 287 | { 288 | if(!FileExists(CFG.chConfigFile))return true; 289 | string strContent; 290 | ifstream inFile(CFG.chConfigFile); 291 | if (inFile) 292 | { 293 | std::string strContent((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); 294 | const char* key= "KEY="; 295 | for (int i = 0; i <= 3; i++) 296 | { 297 | 298 | char charATi = strContent.at(i); 299 | if (charATi != key[i]) 300 | { 301 | //printf("STRcontent AT [%d] [%c]",i,charATi); 302 | //printf("\n"); 303 | // printf("TRUE AT [%d] [%c]", i, key[i]); 304 | //printf("\n"); 305 | return true; 306 | } 307 | } 308 | } 309 | return false; 310 | } 311 | string Configuration::GetKeyStr() 312 | { 313 | string strContent; 314 | ifstream inFile(CFG.chConfigFile); 315 | string key; 316 | if (inFile && !ShouldOverwriteCFG()) 317 | { 318 | std::string strContent((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); 319 | sscanf(strContent.c_str(), "KEY=%s", &key); 320 | key.shrink_to_fit(); 321 | } 322 | //printf("\n 1 "); 323 | // printf(key.c_str()); 324 | //printf(" 1 \n"); 325 | //printf("KEY ======= %s\n",key); 326 | return key; 327 | } 328 | bool Configuration::UpdateConfigFromFile() 329 | { 330 | string strContent; 331 | ifstream inFile(CFG.chConfigFile); 332 | if (inFile) 333 | { 334 | std::string strContent((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); 335 | char Watermark[64] = "FALSE"; 336 | char Aim[64] = "FALSE"; 337 | char Vischeck[64] = "FALSE"; 338 | char leftAim[64] = "FALSE"; 339 | char Semiaim[64] = "FALSE"; 340 | char DynamicSmooth[64] = "FALSE"; 341 | char RSMOOTH[64] = "FALSE"; 342 | char DRAWFOV[64] = "FALSE"; 343 | char RANDBONE[64] = "FALSE"; 344 | char CLOSEBONE[64] = "FALSE"; 345 | char PlGLOW[64] = "FALSE"; 346 | char ITGLOW[64] = "FALSE"; 347 | char ESP[64] = "FALSE"; 348 | char BSHADOW[64] = "FALSE"; 349 | char ESPNAME[64] = "FALSE"; 350 | char SCALENAME[64] = "FALSE"; 351 | char SHNAME[64] = "FALSE"; 352 | char DIST[64] = "FALSE"; 353 | char SCALEDIST[64] = "FALSE"; 354 | char SHDIST[64] = "FALSE"; 355 | char ESPHEALTH[64] = "FALSE"; 356 | char ESPARMOR[64] = "FALSE"; 357 | char LINES[64] = "FALSE"; 358 | char AUTOUPDATE[64] = "FALSE"; 359 | char key[128] = ""; 360 | sscanf(strContent.c_str(), "KEY=%s\nMARK=%s\nAim_Key=0x%X\nAIMBOT=%s\nVISCHECK=%s\nLEFTAIM=%s\nSEMI_AIM=%s\nDSMOOTH=%s\nBONEID=%d\nFoV=%f\nRSMOOTH=%s\nMAXSmooth=%f\nMINSMOOTH=%f\nDRAWFOV=%s\nRANDBONE=%s\nCLOSEBONE=%s\nPlGLOW=%s\nITGLOW=%s\nESP=%s\nBSHADOW=%s\nBSHDAMT=%f\nESPNAME=%s\nSCALENAME=%s\nSHNAME=%s\nNSHAMT=%f\nDIST=%s\nSCALEDIST=%s\nSHDIST=%s\nDSHAMT=%f\nESPHEALTH=%s\nESPARMOR=%s\nLINES=%s\nLINETYPE=%d\nBOXTYPE=%d\nINITFROMCFG=%s",&key, &Watermark, &CFG.dwAimKey, &Aim, &Vischeck, &leftAim, &Semiaim, &DynamicSmooth, &CFG.bone, &CFG.Fov, &RSMOOTH, &CFG.flSmooth, &CFG.MinSmooth, &DRAWFOV, &RANDBONE, &CLOSEBONE, &PlGLOW, &ITGLOW, &ESP, &BSHADOW, &CFG.flBoxDark, &ESPNAME,&SCALENAME, &SHNAME, &CFG.flNameDark, &DIST, &SCALEDIST, &SHDIST, &CFG.flDistDark, &ESPHEALTH, &ESPARMOR, &LINES, &CFG.lineType, &CFG.dwBoxType, &AUTOUPDATE); 361 | 362 | if (strcmp(Watermark, "TRUE") == 0) 363 | CFG.bWatermark = true; 364 | else 365 | CFG.bWatermark = false; 366 | if (strcmp(Aim, "TRUE") == 0) 367 | CFG.bAimbot = true; 368 | else 369 | CFG.bAimbot = false; 370 | if (strcmp(Vischeck, "TRUE") == 0) 371 | CFG.bVischeck = true; 372 | else 373 | CFG.bVischeck= false; 374 | 375 | if (strcmp(leftAim, "TRUE") == 0) 376 | CFG.bLeftClickAim = true; 377 | else 378 | CFG.bLeftClickAim = false; 379 | 380 | if (strcmp(Semiaim, "TRUE") == 0) 381 | CFG.Safebot = true; 382 | else 383 | CFG.Safebot = false; 384 | 385 | if (strcmp(DynamicSmooth, "TRUE") == 0) 386 | CFG.DyanamicSmooth = true; 387 | else 388 | CFG.DyanamicSmooth = false; 389 | if (strcmp(RSMOOTH, "TRUE") == 0) 390 | CFG.RandomizeSmoothness = true; 391 | else 392 | CFG.RandomizeSmoothness = false; 393 | if (strcmp(DRAWFOV, "TRUE") == 0) 394 | CFG.DrawFoV = true; 395 | else 396 | CFG.DrawFoV = false; 397 | if (strcmp(RANDBONE, "TRUE") == 0) 398 | CFG.bRandomBones = true; 399 | else 400 | CFG.bRandomBones = false; 401 | if (strcmp(CLOSEBONE, "TRUE") == 0) 402 | CFG.bClosestBone = true; 403 | else 404 | CFG.bClosestBone = false; 405 | if (strcmp(PlGLOW, "TRUE") == 0) 406 | CFG.bGlowPlayers = true; 407 | else 408 | CFG.bGlowPlayers = false; 409 | if (strcmp(ITGLOW, "TRUE") == 0) 410 | CFG.bGlowItems = true; 411 | else 412 | CFG.bGlowItems = false; 413 | if (strcmp(ESP, "TRUE") == 0) 414 | CFG.bESP = true; 415 | else 416 | CFG.bESP = false; 417 | if (strcmp(BSHADOW, "TRUE") == 0) 418 | CFG.bDarkenBox = true; 419 | else 420 | CFG.bDarkenBox = false; 421 | if (strcmp(ESPNAME, "TRUE") == 0) 422 | CFG.bNames = true; 423 | else 424 | CFG.bNames = false; 425 | if (strcmp(SHNAME, "TRUE") == 0) 426 | CFG.bDarkenName = true; 427 | else 428 | CFG.bDarkenName = false; 429 | if (strcmp(DIST, "TRUE") == 0) 430 | CFG.bDistance = true; 431 | else 432 | CFG.bDistance = false; 433 | if (strcmp(SHDIST, "TRUE") == 0) 434 | CFG.bDarkenDistance = true; 435 | else 436 | CFG.bDarkenDistance = false; 437 | if (strcmp(ESPHEALTH, "TRUE") == 0) 438 | CFG.bHealth = true; 439 | else 440 | CFG.bHealth = false; 441 | if (strcmp(ESPARMOR, "TRUE") == 0) 442 | CFG.bArmor = true; 443 | else 444 | CFG.bArmor = false; 445 | 446 | if (strcmp(LINES, "TRUE") == 0) 447 | CFG.bLines = true; 448 | else 449 | CFG.bLines = false; 450 | if (strcmp(AUTOUPDATE, "TRUE") == 0) 451 | CFG.InitializeFromConfig = true; 452 | else 453 | CFG.InitializeFromConfig = false; 454 | 455 | if (strcmp(SCALENAME, "TRUE") == 0) 456 | CFG.bScaleNames = true; 457 | else 458 | CFG.bScaleNames = false; 459 | if (strcmp(SCALEDIST, "TRUE") == 0) 460 | CFG.bScaleDistance = true; 461 | else 462 | CFG.bScaleDistance = false; 463 | if (key!="NULL") 464 | CFG.strKey = key; 465 | inFile.close(); 466 | return true; 467 | } 468 | return false; 469 | } 470 | 471 | bool Configuration::InitializeConfig() 472 | { 473 | return WriteToConfigFile() && UpdateConfigFromFile(); 474 | } -------------------------------------------------------------------------------- /mhyprotPOC/CFG.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ApexLegends.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include "imgui/imgui.h" 8 | 9 | 10 | inline namespace Configuration 11 | { 12 | class Settings : public Singleton 13 | { 14 | public: 15 | int dwMajor = 1; 16 | int dwMinor = 2; 17 | //MISC 18 | const char* BoxTypes[2] = { "Full Box","Cornered Box" }; 19 | const char* LineTypes[3] = { "Bottom To Enemy","Top To Enemy"," Crosshair To Enemy" }; 20 | string BoneName = "Stomach"; 21 | const char* BoneNamess[5] = { "Head","neck","UpperChest","Chest","Stomach" }; 22 | int BoneIds[5] = { 8,7,5,3,2 }; 23 | bool bWatermark = true; 24 | bool bActive = true; 25 | bool bSaveKey = false; 26 | string strKey = ""; 27 | 28 | // 29 | const char* chConfigDirectory = "C:/Jaguar/"; 30 | const char* chConfigFile = "C:/Jaguar/LunewareApex.txt"; 31 | 32 | // 33 | 34 | int dwAimKey = 0x12; // 0x12 = alt 0x6 = XBTN2 35 | 36 | //Aimbot 37 | bool bAimbot = true; 38 | bool bVischeck = false; 39 | bool bLeftClickAim = false; 40 | bool Safebot = false; 41 | bool DyanamicSmooth = false; 42 | int bone = 2; 43 | float Fov = 20.f; 44 | 45 | bool RandomizeSmoothness = false; 46 | float flSmooth = 60.f; 47 | float MinSmooth = 50.f; 48 | 49 | bool DrawFoV = false; 50 | // 51 | bool bRandomBones = false; 52 | bool bClosestBone = true; 53 | // 54 | //ESP Configuration 55 | bool bGlowPlayers = false; 56 | bool bGlowItems = false; 57 | bool bESP = true; 58 | ImColor BoxVisColor = ImColor(255.f/255,0.f,0.f,1.f); 59 | float flBoxVColors[4] = { 255.f/255,0.f,0.f,1.f };// 60 | ImColor BoxInViscolor = ImColor(0.f, 0.f, 255.f/255, 1.f); 61 | float flBoxInvisColors[4] = { 0.f,0.f,255.f/255,1.f };// 62 | bool bDarkenBox = false; 63 | float flBoxDark = 0.3; 64 | 65 | bool bNames = false; 66 | bool bScaleNames = false; 67 | bool bDarkenName = false; 68 | float flNameDark = 0.7; 69 | 70 | bool bDistance = false; 71 | bool bScaleDistance = false; 72 | bool bDarkenDistance = false; 73 | float flDistDark = 0.7; 74 | 75 | bool bHealth = false; 76 | ImColor HealthBarColor = ImColor(0.f, 255.f/255.f, 0.f, 1.f); 77 | float HealthBar[4] = { 0.f,255.f/255,0.f,1.f };// 78 | bool bArmor = false; 79 | ImColor ArmorBarColor = ImColor(105.f/255, 13.f/255, 173.f/255, 1.f); 80 | float ArmorBar[4] = { 105.f/255, 13.f/255, 173.f/255, 1 };// 81 | int dwBoxType= 0; 82 | // Lines 83 | bool bLines = false; 84 | int lineType = 0; // 0 bottom to enemy, 1 top TO enemy 2 , crosshair to enemy 85 | ImColor LineColor = ImColor(0.f, 0.f, 255.f/255, 1.f); 86 | float LineColors[4] = { 0,0,255.f/255,1 }; // 87 | //Universal 88 | float MaxDistance = 300.f; 89 | bool InitializeFromConfig = FALSE; 90 | }; 91 | #define CFG Configuration::Settings::Get() 92 | void cfg(); 93 | bool FileExists(const char* chDir); 94 | bool WriteToConfigFile(); 95 | bool UpdateConfigFromFile(); 96 | bool InitializeConfig(); 97 | bool ShouldAutoInitFromFile(); 98 | bool ShouldOverwriteCFG(); 99 | string GetKeyStr(); 100 | } -------------------------------------------------------------------------------- /mhyprotPOC/LunewareApex.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/LunewareApex.aps -------------------------------------------------------------------------------- /mhyprotPOC/LunewareApex.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource1.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource1.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Font 51 | // 52 | 53 | IDR_FONT1 FONT "fonts\\iLunarian.ttf" 54 | 55 | IDR_FONT2 FONT "fonts\\Century_Gothic.ttf" 56 | 57 | IDR_FONT3 FONT "fonts\\kalra.ttf" 58 | 59 | #endif // English (United States) resources 60 | ///////////////////////////////////////////////////////////////////////////// 61 | 62 | 63 | 64 | #ifndef APSTUDIO_INVOKED 65 | ///////////////////////////////////////////////////////////////////////////// 66 | // 67 | // Generated from the TEXTINCLUDE 3 resource. 68 | // 69 | 70 | 71 | ///////////////////////////////////////////////////////////////////////////// 72 | #endif // not APSTUDIO_INVOKED 73 | 74 | -------------------------------------------------------------------------------- /mhyprotPOC/Maths.cpp: -------------------------------------------------------------------------------- 1 | #include "Maths.h" 2 | #include "ApexPrediction.h" 3 | 4 | float Maths::FPS(int dwFPS) 5 | { 6 | return (float)(1000 / dwFPS); 7 | } 8 | 9 | int Maths::RNG(int dwArray[]) 10 | { 11 | return dwArray[rand() % 5]; 12 | } 13 | 14 | float Maths::fRNG(float flMin, float flMax) 15 | { 16 | return (flMin + static_cast (rand()) / (static_cast (RAND_MAX / (flMax - flMin)))); 17 | } 18 | 19 | float Maths::ToRadians(float flVal) 20 | { 21 | return (float)(M_PI / 180.0f) * flVal; 22 | } 23 | 24 | float Maths::ToDegree(float flVal) 25 | { 26 | return (float)(180.0f / M_PI) * flVal; 27 | } 28 | 29 | int Maths::Quadrant(Vector2 vecCoordinate) 30 | { 31 | if (vecCoordinate.X > 0 && vecCoordinate.Y > 0) 32 | return 1; 33 | else if (vecCoordinate.X < 0 && vecCoordinate.Y > 0) 34 | return 2; 35 | else if (vecCoordinate.X < 0 && vecCoordinate.Y < 0) 36 | return 3; 37 | else if (vecCoordinate.X > 0 && vecCoordinate.Y < 0) 38 | return 4; 39 | return 0; 40 | } 41 | 42 | void Maths::NormalizeDelta(Vector2 vecCoordinate, Vector2 vecDelta) 43 | { 44 | int dwQuadrant = Quadrant(vecCoordinate); 45 | if (dwQuadrant == 1) 46 | { 47 | if (vecCoordinate.X < 0) 48 | vecDelta.X = fabsf(vecCoordinate.X); 49 | if (vecCoordinate.Y < 0) 50 | vecDelta.Y = fabsf(vecCoordinate.Y); 51 | } 52 | else if (dwQuadrant == 2) 53 | { 54 | if (vecCoordinate.X > 0) 55 | vecDelta.X *= -1.0f; 56 | if (vecCoordinate.Y < 0) 57 | vecDelta.Y = fabsf(vecCoordinate.Y); 58 | } 59 | else if (dwQuadrant == 3) 60 | { 61 | if (vecCoordinate.X > 0) 62 | vecDelta.X *= -1.0f; 63 | if (vecCoordinate.Y > 0) 64 | vecDelta.Y *= -1.0f; 65 | } 66 | else if (dwQuadrant == 4) 67 | { 68 | if (vecCoordinate.X < 0) 69 | vecDelta.X = fabsf(vecDelta.X); 70 | if (vecCoordinate.Y > 0) 71 | vecDelta.Y *= -1.0f; 72 | } 73 | } 74 | Vector3 Maths::CalculateAimAngle(Vector3 vecSource, Vector3 vecDestination,Vector3 LocalSway, Vector3 LocalCam, float flSmooth) 75 | { 76 | /* 77 | Vector3 vecDelta; 78 | vecDelta.X = vecDestination.X - vecSource.X; 79 | vecDelta.Y = vecDestination.Y - vecSource.Y; 80 | vecDelta.Z = vecDestination.Z - vecSource.Z; 81 | float flHypotenuse = Hypotenuse2D(vecDelta); 82 | Vector3 vecAngle; 83 | vecAngle.X = atan2f(-vecDelta.Z, flHypotenuse) * (float)(180.0f / M_PI); 84 | vecAngle.Y = atan2f(vecDelta.Y, vecDelta.X) * (float)(180.0f / M_PI); 85 | vecAngle.Z = 0.0f; 86 | vecAngle = vecAngle - (LocalSway - LocalCam); 87 | Vector3 Delta = vecAngle - LocalCam; 88 | Vector3 SmoothedAngles = LocalCam + (Delta / flSmooth); 89 | SmoothedAngles.Z = 0.f; 90 | return FinalizeAngle( SmoothedAngles); 91 | */ 92 | Vector3 angle; 93 | vecSource.Z += 30.f; 94 | Vector3 delta = { (vecSource.X - vecDestination.X), (vecSource.Y - vecDestination.Y), (vecSource.Z - vecDestination.Z) }; 95 | float hyp = Hypotenuse(delta); 96 | angle.X = atan(delta.Z / hyp) * (180.0f / M_PI); 97 | angle.Y = atan(delta.Y / delta.X) * (180.0f / M_PI); 98 | angle.Z = 0; 99 | if (delta.X >= 0.0) angle.Y += 180.0f; 100 | return angle; 101 | } 102 | Vector3 Maths::CalculateAngle(Vector3 vecSource, Vector3 vecDestination) 103 | { 104 | Vector3 angle; 105 | 106 | Vector3 delta = { (vecSource.X - vecDestination.X), (vecSource.Y - vecDestination.Y), (vecSource.Z - vecDestination.Z) }; 107 | double hyp = sqrt(delta.X * delta.X + delta.Y * delta.Y); 108 | angle.X = atan(delta.Z / hyp) * (180.0f / M_PI); 109 | angle.Y = atan(delta.Y / delta.X) * (180.0f / M_PI); 110 | angle.Z = 0; 111 | if (delta.X >= 0.0) angle.Y += 180.0f; 112 | 113 | return angle; 114 | } 115 | 116 | Vector3 Maths::ClampAngle(Vector3 vecAngle) 117 | { 118 | Vector3 clampedVector = vecAngle; 119 | if (clampedVector.X > 89.0f) 120 | { 121 | clampedVector.X -= 179.0f; 122 | } 123 | if (clampedVector.X < -89.0f) 124 | { 125 | clampedVector.X += 179.0f; 126 | } 127 | if (clampedVector.Y > 179.0f) 128 | { 129 | clampedVector.Y -= 360.0f; 130 | } 131 | if (clampedVector.Y < -179.0f) 132 | { 133 | clampedVector.Y += 360.0f; 134 | } 135 | if (clampedVector.X < -89.0f) 136 | { 137 | clampedVector.X = -89.0f; 138 | } 139 | if (clampedVector.X > 89.0f) 140 | { 141 | clampedVector.X = 89.0f; 142 | } 143 | if (clampedVector.Y > 179.0f) 144 | { 145 | clampedVector.Y = 179.0f; 146 | } 147 | if (clampedVector.Y < -179.0f) 148 | { 149 | clampedVector.Y = -179.0f; 150 | } 151 | clampedVector.Z = 0.0f; 152 | return clampedVector; 153 | } 154 | 155 | Vector3 Maths::NormalizeAngle(Vector3 vecAngle) 156 | { 157 | Vector3 normalizedAngles = vecAngle; 158 | if (normalizedAngles.X > 89.0f) 159 | { 160 | normalizedAngles.X = 89.0f; 161 | } 162 | else if (-89.0f > normalizedAngles.X) 163 | { 164 | normalizedAngles.X = -89.0f; 165 | } 166 | 167 | if (normalizedAngles.Y > 180.0f) 168 | { 169 | normalizedAngles.Y -= 360.0f; 170 | } 171 | else if (-180.0f > normalizedAngles.Y) 172 | { 173 | normalizedAngles.Y += 360.0f; 174 | } 175 | normalizedAngles.Z = 0.0f; 176 | return normalizedAngles; 177 | } 178 | 179 | Vector3 Maths::FinalizeAngle(Vector3 vecAngle) 180 | { 181 | return NormalizeAngle(ClampAngle(vecAngle)); 182 | } 183 | QAngle Maths::FinalQAngle(QAngle Angle) 184 | { 185 | Vector3 Ang = { Angle.x,Angle.y,Angle.z }; 186 | Vector3 angle = Maths::FinalizeAngle(Ang); 187 | return QAngle(angle.X, angle.Y, angle.Z); 188 | } 189 | Vector2 Maths::AimAngleToRelatives(Vector3 vecViewAngle, Vector3 vecTargetAngle, float flSensitivity, float flZoomSensitivity, float flSmooth, bool bScoping) 190 | { 191 | float flAimX; 192 | float flAimY; 193 | float flMouseAimX; 194 | float flMouseAimY; 195 | Vector2 vecAimRelatives; 196 | flAimY = vecViewAngle.X - vecTargetAngle.X, flAimX = vecViewAngle.Y - vecTargetAngle.Y; 197 | if (!bScoping) 198 | { 199 | flAimX = ((flAimX / flSensitivity) / 0.022f); 200 | flAimY = ((flAimY / flSensitivity) / -0.022f); 201 | } 202 | else 203 | { 204 | flAimX = ((flAimX / flZoomSensitivity) / 0.022f); 205 | flAimY = ((flAimY / flZoomSensitivity) / -0.022f); 206 | } 207 | if (flSmooth > 1.0f) 208 | { 209 | flMouseAimX = 0.0f, flMouseAimY = 0.0f; 210 | if (flMouseAimX < flAimX) 211 | { 212 | flMouseAimX += 1.0f + (flAimX / flSmooth); 213 | } 214 | else if (flMouseAimX > flAimX) 215 | { 216 | flMouseAimX -= 1.0f - (flAimX / flSmooth); 217 | } 218 | if (flMouseAimY < flAimY) 219 | { 220 | flMouseAimY += 1.0f + (flAimY / flSmooth); 221 | } 222 | else if (flMouseAimY > flAimY) 223 | { 224 | flMouseAimY -= 1.0f - (flAimY / flSmooth); 225 | } 226 | } 227 | else 228 | { 229 | flMouseAimX = flAimX; 230 | flMouseAimY = flAimY; 231 | } 232 | vecAimRelatives.X = flMouseAimX; 233 | vecAimRelatives.Y = flMouseAimY; 234 | return vecAimRelatives; 235 | } 236 | 237 | float Maths::CalculateFoV(Vector3 vecLocalPosition, Vector3 vecTargetPosition, Vector3 vecDestination, Vector3 vecViewAngle) 238 | { 239 | float flPitchDifference = fabsf(vecViewAngle.X - vecDestination.X); 240 | float flYawDifference = fabsf(vecViewAngle.Y - vecDestination.Y); 241 | float flDistance = vecTargetPosition.Distance(vecLocalPosition); 242 | float flPitchDistance = sinf(ToRadians(flPitchDifference)) * flDistance; 243 | float flYawDistance = sinf(ToRadians(flYawDifference)) * flDistance; 244 | float flRealDistance = sqrtf((flPitchDistance * flPitchDistance) + (flYawDistance * flYawDistance)); 245 | if (flYawDifference <= 90.0f) 246 | { 247 | return flRealDistance; 248 | } 249 | else 250 | { 251 | return 666.0f; 252 | } 253 | } 254 | 255 | float Maths::CalculateMaxAimValue(float flSensitivity) 256 | { 257 | return (2.5f * (powf(flSensitivity, 2.0f))) - (24.5f * flSensitivity) + 71.0f; 258 | } 259 | 260 | Vector2 Maths::WorldToMap(Vector3 vecPosition, Vector2 vecWorldOrigin, float flScale) 261 | { 262 | Vector2 vecOffset; 263 | vecOffset.X = (vecPosition.X - vecWorldOrigin.X) / flScale; 264 | vecOffset.Y = (vecPosition.Y - vecWorldOrigin.Y) / -flScale; 265 | return vecOffset; 266 | } 267 | 268 | float Maths::Hypotenuse(Vector3 vecDelta) 269 | { 270 | return sqrtf((vecDelta.X * vecDelta.X) + (vecDelta.Y * vecDelta.Y) + (vecDelta.Z * vecDelta.Z)); 271 | } 272 | 273 | float Maths::Hypotenuse2D(Vector3 vecDelta) 274 | { 275 | return sqrtf((vecDelta.X * vecDelta.X) + (vecDelta.Y * vecDelta.Y)); 276 | } 277 | 278 | float Maths::CalculateDistance(Vector3 vecStart, Vector3 vecDestination) 279 | { 280 | Vector3 vecDelta; 281 | vecDelta.X = vecStart.X - vecDestination.X; 282 | vecDelta.Y = vecStart.Y - vecDestination.Y; 283 | vecDelta.Z = vecStart.Z - vecDestination.Z; 284 | return Hypotenuse(vecDelta); 285 | } 286 | 287 | float Maths::CalculateFoV(Vector3 vecDestination, Vector3 vecViewAngle) 288 | { 289 | Vector3 vecDelta = vecDestination - vecViewAngle; 290 | return sqrtf(powf(vecDelta.X, 2.0f) + powf(vecDelta.Y, 2.0f)); 291 | } 292 | 293 | 294 | QAngle Maths::CalculatePredictionAngle(uintptr_t pLocalPlayer, QAngle LocalCam, QAngle LocalSway, Vector TargetBone, Vector TargetAbsVelocity, float smooth) { 295 | QAngle CalculatedAngles = QAngle(0, 0, 0); 296 | WeaponXEntity curweap = WeaponXEntity(); 297 | curweap.update(pLocalPlayer); 298 | float BulletSpeed = curweap.get_projectile_speed(); 299 | float BulletGrav = curweap.get_projectile_gravity(); 300 | Vector StartPos = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 301 | //if (StartPos.DistTo(TargetBone) < 75.f * 15) 302 | // StartPos.z += 10.f; 303 | // else StartPos.z += 5.f; 304 | if (BulletSpeed > 1.f) 305 | { 306 | PredictCtx Ctx; 307 | Ctx.StartPos = StartPos; 308 | Ctx.TargetPos = TargetBone; 309 | Ctx.BulletSpeed = BulletSpeed;// - (BulletSpeed * 0.08); 310 | Ctx.BulletGravity = BulletGrav; 311 | Ctx.TargetVel = TargetAbsVelocity; 312 | 313 | if (BulletPredict(Ctx)) { 314 | CalculatedAngles = QAngle{ Ctx.AimAngles.x, Ctx.AimAngles.y, 0.f }; 315 | } 316 | 317 | } 318 | if (CalculatedAngles == QAngle(0, 0, 0)) { 319 | CalculatedAngles = Maths::CalcAngle(StartPos, TargetBone); 320 | } 321 | CalculatedAngles -= LocalSway - LocalCam; 322 | Maths::NormalizeAngles(CalculatedAngles); 323 | QAngle Delta = CalculatedAngles - LocalCam; 324 | Maths::NormalizeAngles(Delta); 325 | QAngle SmoothedAngles = LocalCam + (Delta / smooth); 326 | SmoothedAngles.z = 0.f; 327 | return SmoothedAngles; 328 | } 329 | 330 | 331 | QAngle Maths::CalcAngle(Vector& src, Vector& dst) 332 | { 333 | QAngle angle = QAngle(); 334 | Vector delta = Vector((src.x - dst.x), (src.y - dst.y), (src.z - dst.z)); 335 | 336 | double hyp = sqrtf(delta.x * delta.x + delta.y * delta.y); 337 | 338 | angle.x = atanf(delta.z / hyp) * (180.0f / M_PI); 339 | angle.y = atanf(delta.y / delta.x) * (180.0f / M_PI); 340 | angle.z = 0; 341 | if (delta.x >= 0.0) angle.y += 180.0f; 342 | 343 | return angle; 344 | } 345 | 346 | Vector3 Maths::SmoothifyAngle(Vector3 vecViewAngle, Vector3 vecAngle, float flSmooth) 347 | { 348 | Vector3 smoothifiedAngle; 349 | Vector3 vecDeltaAngle = vecAngle - vecViewAngle; 350 | vecAngle.X = vecViewAngle.X - vecDeltaAngle.X / flSmooth; 351 | vecAngle.Y = vecViewAngle.Y - vecDeltaAngle.Y / flSmooth; 352 | vecAngle.Z = 0.0f; 353 | smoothifiedAngle = vecAngle; 354 | return smoothifiedAngle; 355 | } 356 | 357 | void Maths::NormalizeAngles(QAngle& angle) 358 | { 359 | while (angle.x > 89.0f) 360 | angle.x -= 180.f; 361 | 362 | while (angle.x < -89.0f) 363 | angle.x += 180.f; 364 | 365 | while (angle.y > 180.f) 366 | angle.y -= 360.f; 367 | 368 | while (angle.y < -180.f) 369 | angle.y += 360.f; 370 | } 371 | 372 | 373 | float Maths::FoV(float flFoV) 374 | { 375 | return flFoV * 10.0f; 376 | } 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | /////////////////////////////////////////////////////////////////////////////////////////////// WeaponXEntity for APEX LEGENDS 393 | 394 | void WeaponXEntity::update(uintptr_t LocalPlayer) 395 | { 396 | uintptr_t wephandle = Memory::ReadProcessMemory(APEXVars.dwProcessId, LocalPlayer + APEXOffsets.OFFSET_WEAPON); //ptr to player weapon 397 | wephandle &= 0xffff; 398 | uintptr_t wep_entity = ApexLegends::GetEntityBase(wephandle); 399 | projectile_speed = Memory::ReadProcessMemory(APEXVars.dwProcessId, wep_entity + APEXOffsets.OFFSET_BULLET_SPEED); 400 | projectile_scale = Memory::ReadProcessMemory(APEXVars.dwProcessId, wep_entity + APEXOffsets.OFFSET_BULLET_SCALE); 401 | zoom_fov = Memory::ReadProcessMemory(APEXVars.dwProcessId, wep_entity + APEXOffsets.OFFSET_ZOOM_FOV); 402 | } 403 | 404 | float WeaponXEntity::get_projectile_speed() 405 | { 406 | return projectile_speed; 407 | } 408 | 409 | float WeaponXEntity::get_projectile_gravity() 410 | { 411 | return 750.0f * projectile_scale; 412 | } 413 | 414 | float WeaponXEntity::get_zoom_fov() 415 | { 416 | return zoom_fov; 417 | } 418 | double Maths::GetFov(const QAngle& viewAngle, const QAngle& aimAngle) 419 | { 420 | QAngle delta = aimAngle - viewAngle; 421 | NormalizeAngles(delta); 422 | return sqrt(pow(delta.x, 2.0f) + pow(delta.y, 2.0f)); 423 | } 424 | -------------------------------------------------------------------------------- /mhyprotPOC/Maths.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "Structs.h" 5 | #include "ApexLegends.h" 6 | # define M_PI 3.14159265358979323846 7 | 8 | namespace Maths 9 | { 10 | float FPS(int dwFPS); 11 | int RNG(int dwArray[]); 12 | float fRNG(float flMin, float flMax); 13 | float ToRadians(float flVal); 14 | float ToDegree(float flVal); 15 | int Quadrant(Vector2 vecCoordinate); 16 | void NormalizeDelta(Vector2 vecCoordinate, Vector2 vecDelta); 17 | Vector3 ClampAngle(Vector3 vecAngle); 18 | Vector3 NormalizeAngle(Vector3 vecAngle); 19 | Vector3 FinalizeAngle(Vector3 vecAngle); 20 | Vector2 AimAngleToRelatives(Vector3 vecViewAngle, Vector3 vecTargetAngle, float flSensitivity, float flZoomSensitivity, float flSmooth, bool bScoping); 21 | float CalculateFoV(Vector3 vecLocalPosition, Vector3 vecTargetPosition, Vector3 vecDestination, Vector3 vecViewAngle); 22 | float CalculateMaxAimValue(float flSensitivity); 23 | Vector2 WorldToMap(Vector3 vecPosition, Vector2 vecWorldOrigin, float flScale); 24 | int RNG(int dwArray[]); 25 | float Hypotenuse(Vector3 vecDelta); 26 | float Hypotenuse2D(Vector3 vecDelta); 27 | float ToRadians(float flVal); 28 | float CalculateDistance(Vector3 vecStart, Vector3 vecDestination); 29 | float CalculateFoV(Vector3 vecDestination, Vector3 vecViewAngle); 30 | QAngle CalculatePredictionAngle(uintptr_t pLocalPlayer, QAngle LocalCam, QAngle LocalSway, Vector TargetBone, Vector TargetAbsVelocity, float smooth); 31 | QAngle CalcAngle(Vector& src, Vector& dst); 32 | Vector3 CalculateAngle(Vector3 vecSource, Vector3 vecDestination); 33 | Vector3 CalculateAimAngle(Vector3 vecSource, Vector3 vecDestination, Vector3 LocalSway, Vector3 LocalCam, float flSmooth); 34 | Vector3 SmoothifyAngle(Vector3 vecViewAngle, Vector3 vecAngle, float flSmooth); 35 | void NormalizeAngles(QAngle& angle); 36 | Vector3 NormalizeAngle(Vector3 pAngle); 37 | Vector3 FinalizeAngle(Vector3 pAngle); 38 | QAngle FinalQAngle(QAngle Angle); 39 | float FoV(float flFoV); 40 | double GetFov(const QAngle& viewAngle, const QAngle& aimAngle); 41 | } 42 | class WeaponXEntity 43 | { 44 | public: 45 | void update(uintptr_t LocalPlayer); 46 | float get_projectile_speed(); 47 | float get_projectile_gravity(); 48 | float get_zoom_fov(); 49 | 50 | private: 51 | float projectile_scale; 52 | float projectile_speed; 53 | float zoom_fov; 54 | }; -------------------------------------------------------------------------------- /mhyprotPOC/Memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Memory 6 | { 7 | template 8 | static inline Type Ptr(Base pBase, Offset pOffset) 9 | { 10 | static_assert(std::is_pointer::value || std::is_integral::value, "[MEMASSERT] Type must be a pointer or address"); 11 | static_assert(std::is_pointer::value || std::is_integral::value, "[MEMASSERT] Base must be a pointer or address"); 12 | static_assert(std::is_pointer::value || std::is_integral::value, "[MEMASSERT] Offset must be a pointer or address"); 13 | return pBase ? reinterpret_cast((reinterpret_cast(pBase) + static_cast(pOffset))) : nullptr; 14 | } 15 | 16 | template 17 | static bool IsValidPtr(Type* ptr) 18 | { 19 | return (ptr && sizeof(ptr)) ? true : false; 20 | } 21 | 22 | static bool IsValidPtr(void* ptr) 23 | { 24 | return (ptr && sizeof(ptr)) ? true : false; 25 | } 26 | 27 | static bool ReadProcessMemory(DWORD dwProcessId, uint64_t pAddress, void* pBuffer, size_t szBufferSize) 28 | { 29 | if (IsValidPtr((void*)pAddress) && pAddress != 0) 30 | { 31 | return mhyprotrose::MhyReadProcessMemory(dwProcessId, pAddress, pBuffer, szBufferSize); 32 | } 33 | return false; 34 | } 35 | 36 | template 37 | static Type ReadProcessMemory(DWORD dwProcessId, uint64_t pAddress) 38 | { 39 | Type tBuffer{}; 40 | if (IsValidPtr((void*)pAddress) && pAddress != 0) 41 | { 42 | tBuffer = mhyprotrose::MhyReadProcessMemory(dwProcessId, pAddress); 43 | } 44 | return tBuffer; 45 | } 46 | 47 | static bool ReadVirtualMemory(uint64_t pAddress, uint8_t* pBuffer, size_t szSize) 48 | { 49 | return mhyprotrose::MhyReadKernelMemory(pAddress, pBuffer, szSize); 50 | } 51 | 52 | template 53 | Type ReadVirtualMemory(uint64_t pAddress) 54 | { 55 | Type tBuffer; 56 | ReadVirtualMemory(pAddress, (uint8_t*)&tBuffer, sizeof(Type)); 57 | return tBuffer; 58 | } 59 | 60 | template 61 | static bool WriteProcessMemory(DWORD dwProcessId, uintptr_t pAddress, Type tBuffer) 62 | { 63 | if (pAddress != 0) 64 | return mhyprotrose::MhyWriteProcessMemory(dwProcessId, pAddress, tBuffer); 65 | else return false; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /mhyprotPOC/Overlay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "XorStr.h" 3 | #include "imgui/imgui.h" 4 | #include "imgui/imgui.h" 5 | #include "imgui/imgui.h" 6 | #include "imgui/imgui_impl_dx9.h" 7 | #include "imgui/imgui_impl_win32.h" 8 | #include 9 | #pragma comment(lib, "d3d9.lib") 10 | #include 11 | #pragma comment(lib, "d3dx9.lib") 12 | #include 13 | #include 14 | #include "ApexLegends.h" 15 | #include "CFG.h" 16 | #include "Maths.h" 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "HTTPDownloader.hpp" 22 | #include 23 | #include "resource1.h" 24 | #include 25 | 26 | 27 | 28 | 29 | 30 | 31 | inline string string_To_UTF8(const std::string& str) 32 | { 33 | int nwLen = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0); 34 | 35 | wchar_t* pwBuf = new wchar_t[nwLen + 1]; 36 | ZeroMemory(pwBuf, nwLen * 2 + 2); 37 | 38 | ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen); 39 | 40 | int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL); 41 | 42 | char* pBuf = new char[nLen + 1]; 43 | ZeroMemory(pBuf, nLen + 1); 44 | 45 | ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL); 46 | 47 | std::string retStr(pBuf); 48 | 49 | delete[]pwBuf; 50 | delete[]pBuf; 51 | 52 | pwBuf = NULL; 53 | pBuf = NULL; 54 | 55 | return retStr; 56 | } 57 | 58 | #define GREEN ImColor(0, 255, 0) 59 | #define RED ImColor(255, 0, 0) 60 | #define BLUE ImColor(0, 0, 255) 61 | #define ORANGE ImColor(255, 165, 0) 62 | #define WHITE ImColor(255, 255, 255) 63 | 64 | static ImGuiStyle imGuiStyle; 65 | static bool fontIsInstalled = false; 66 | static int currentMenu = 0; 67 | static bool pushCalled = false; 68 | static bool executedOnce = false; 69 | 70 | 71 | typedef struct visuals 72 | { 73 | bool box = true; 74 | bool line = true; 75 | bool distance = true; 76 | bool healthbar = true; 77 | bool shieldbar = true; 78 | bool name = true; 79 | }visuals; 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | class Overlay 91 | { 92 | public: 93 | LONG nv_default = WS_POPUP | WS_CLIPSIBLINGS; 94 | LONG nv_default_in_game = nv_default | WS_DISABLED; 95 | LONG nv_edit = nv_default_in_game | WS_VISIBLE; 96 | LONG nv_ex_default = WS_EX_TOOLWINDOW; 97 | LONG nv_ex_edit = nv_ex_default | WS_EX_LAYERED | WS_EX_TRANSPARENT; 98 | LONG nv_ex_edit_menu = nv_ex_default | WS_EX_TRANSPARENT; 99 | bool bESP; 100 | bool bItemGlow; 101 | bool bPlayerGlow; 102 | bool bAimbot; 103 | float flMaxDist; 104 | float flsmooth; 105 | float flFov; 106 | int dwbone; 107 | int dwwidth; 108 | int dwheight; 109 | bool bLeftclick = false; 110 | bool bIns = false; 111 | bool bMenu = false; 112 | visuals v; 113 | bool bActive; 114 | HWND overlayHWND; 115 | void Start(HWND Overlay_hwnd); 116 | DWORD CreateOverlay(); 117 | void Clear(); 118 | int getWidth(); 119 | int getHeight(); 120 | void RenderInfo(); 121 | void RenderMenu(); 122 | void RenderEsp(int dwEntity); 123 | void ClickThrough(bool v); 124 | void DrawLine(ImVec2 a, ImVec2 b, ImColor color, float width); 125 | void DrawBox(ImColor color, float x, float y, float w, float h); 126 | void Text(ImVec2 pos, ImColor color, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect); 127 | void DrawStrokeText(float x, float y, const char* str); 128 | float DrawOutlinedText(ImFont* pFont, const std::string& text, const ImVec2& pos, float size, ImU32 color, bool center); 129 | void DrawText1(float x, float y, const char* str, ImVec4 color); 130 | void RectFilled(float x0, float y0, float x1, float y1, ImColor color, float rounding, int rounding_corners_flags); 131 | void ProgressBar(float x, float y, float w, float h, int value, int v_max, ImColor barColor, bool Outlined, ImColor Outlinecolor = ImColor(0,0,0)); 132 | void String(ImVec2 pos, ImColor color, const char* text); 133 | void DrawCircle(float x, float y, float radius, ImVec4 color, int segments = 0); 134 | void DrawFilledCircle(float x, float y, float radius, ImVec4 color, int segments = 0 ); 135 | void DrawCorneredBox(float X, float Y, float W, float H, const ImU32& color, float thickness); 136 | void RectFilled(float x0, float y0, float x1, float y1, ImU32 color, float rounding, int rounding_corners_flags); 137 | void RectOutlined(float x0, float y0, float x1, float y1, ImU32 color, float rounding, int rounding_corners_flags); 138 | 139 | private: 140 | bool isInitialized = true; 141 | bool isVisible = true; 142 | }; -------------------------------------------------------------------------------- /mhyprotPOC/Singleton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class Singleton 5 | { 6 | protected: 7 | Singleton() {} 8 | ~Singleton() {} 9 | 10 | Singleton(const Singleton&) = delete; 11 | Singleton& operator=(const Singleton&) = delete; 12 | 13 | Singleton(Singleton&&) = delete; 14 | Singleton& operator=(Singleton&&) = delete; 15 | public: 16 | static T& Get() 17 | { 18 | static T inst{}; 19 | return inst; 20 | } 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /mhyprotPOC/Structs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef STRUCTS_H 3 | #define STRUCTS_H 4 | 5 | #include 6 | #include 7 | 8 | struct Time 9 | { 10 | int Hour; 11 | int Minute; 12 | int Second; 13 | }; 14 | 15 | struct Vector2 16 | { 17 | float X; 18 | float Y; 19 | inline Vector2 operator+(Vector2 pVec) 20 | { 21 | return { X + pVec.X, Y + pVec.Y }; 22 | } 23 | inline Vector2 operator-(Vector2 pVec) 24 | { 25 | return { X - pVec.X, Y - pVec.Y }; 26 | } 27 | inline Vector2 operator*(Vector2 pVec) 28 | { 29 | return { X * pVec.X, Y * pVec.Y }; 30 | } 31 | inline Vector2 operator/(Vector2 pVec) 32 | { 33 | return { X / pVec.X, Y / pVec.Y }; 34 | } 35 | }; 36 | 37 | struct Vector3 38 | { 39 | float X; 40 | float Y; 41 | float Z; 42 | inline Vector3 operator+(Vector3 pVec) 43 | { 44 | return { X + pVec.X, Y + pVec.Y, Z + pVec.Z }; 45 | } 46 | inline Vector3 operator-(Vector3 pVec) 47 | { 48 | return { X - pVec.X, Y - pVec.Y, Z - pVec.Z }; 49 | } 50 | inline Vector3 operator*(Vector3 pVec) 51 | { 52 | return { X * pVec.X, Y * pVec.Y, Z * pVec.Z }; 53 | } 54 | inline void operator*=(float flNum) 55 | { 56 | X = X * flNum; 57 | Y = Y * flNum; 58 | Z = Z * flNum; 59 | } 60 | inline Vector3 operator/(float flNum) 61 | { 62 | return { X / flNum, Y / flNum, Z / flNum }; 63 | } 64 | inline Vector3 operator*(float flNumber) 65 | { 66 | return { X * flNumber, Y * flNumber, Z * flNumber }; 67 | } 68 | inline float Dot(Vector3 pVec) 69 | { 70 | return (X * pVec.X) + (Y * pVec.Y) + (Z * pVec.Z); 71 | } 72 | inline float Distance(const Vector3 pVec) 73 | { 74 | return sqrtf((X - pVec.X) * (X - pVec.X) + (Y - pVec.Y) * (Y - pVec.Y) + (Z - pVec.Z) * (Z - pVec.Z)); 75 | } 76 | inline float Length() 77 | { 78 | return sqrtf(Dot({ X, Y, Z })); 79 | } 80 | }; 81 | 82 | class Vector4 83 | { 84 | public: 85 | float X; 86 | float Y; 87 | float Z; 88 | float W; 89 | inline Vector4 operator+(Vector4 pVec) 90 | { 91 | float vecData[4]; 92 | vecData[0] = pVec.X + X; 93 | vecData[1] = pVec.Y + Y; 94 | vecData[2] = pVec.Z + Z; 95 | vecData[3] = pVec.W + W; 96 | return *(Vector4*)&vecData; 97 | } 98 | inline Vector4 operator-(Vector4 pVec) 99 | { 100 | float vecData[4]; 101 | vecData[0] = pVec.X - X; 102 | vecData[1] = pVec.Y - Y; 103 | vecData[2] = pVec.Z - Z; 104 | vecData[3] = pVec.W - W; 105 | return *(Vector4*)&vecData; 106 | } 107 | inline Vector4 operator/(float flNum) 108 | { 109 | float vecData[4]; 110 | vecData[0] = X / flNum; 111 | vecData[1] = Y / flNum; 112 | vecData[2] = Z / flNum; 113 | vecData[3] = W / flNum; 114 | return *(Vector4*)&vecData; 115 | } 116 | inline Vector4 operator*(float flNum) 117 | { 118 | float vecData[4]; 119 | vecData[0] = X * flNum; 120 | vecData[1] = Y * flNum; 121 | vecData[2] = Z * flNum; 122 | vecData[3] = W * flNum; 123 | return *(Vector4*)&vecData; 124 | } 125 | inline float Dot(Vector4 pVec) 126 | { 127 | return (X * pVec.X) + (Y * pVec.Y) + (Z * pVec.Z) + (W * pVec.W); 128 | } 129 | inline float Length() 130 | { 131 | return sqrtf(Dot({ X, Y, Z })); 132 | } 133 | }; 134 | 135 | struct matrix3x4_t 136 | { 137 | matrix3x4_t() = default; 138 | matrix3x4_t( 139 | float m00, float m01, float m02, float m03, 140 | float m10, float m11, float m12, float m13, 141 | float m20, float m21, float m22, float m23) 142 | { 143 | m_matrix[0][0] = m00; 144 | m_matrix[0][1] = m01; 145 | m_matrix[0][2] = m02; 146 | m_matrix[0][3] = m03; 147 | m_matrix[1][0] = m10; 148 | m_matrix[1][1] = m11; 149 | m_matrix[1][2] = m12; 150 | m_matrix[1][3] = m13; 151 | m_matrix[2][0] = m20; 152 | m_matrix[2][1] = m21; 153 | m_matrix[2][2] = m22; 154 | m_matrix[2][3] = m23; 155 | } 156 | matrix3x4_t(const Vector3& x_axis, const Vector3& y_axis, const Vector3& z_axis, const Vector3& vec_origin) 157 | { 158 | init(x_axis, y_axis, z_axis, vec_origin); 159 | } 160 | 161 | void init(const Vector3& x_axis, const Vector3& y_axis, const Vector3& z_axis, const Vector3& vec_origin) 162 | { 163 | m_matrix[0][0] = x_axis.X; 164 | m_matrix[0][1] = y_axis.X; 165 | m_matrix[0][2] = z_axis.X; 166 | m_matrix[0][3] = vec_origin.X; 167 | m_matrix[1][0] = x_axis.Y; 168 | m_matrix[1][1] = y_axis.Y; 169 | m_matrix[1][2] = z_axis.Y; 170 | m_matrix[1][3] = vec_origin.Y; 171 | m_matrix[2][0] = x_axis.Z; 172 | m_matrix[2][1] = y_axis.Z; 173 | m_matrix[2][2] = z_axis.Z; 174 | m_matrix[2][3] = vec_origin.Z; 175 | } 176 | 177 | float* operator[](int i) 178 | { 179 | return m_matrix[i]; 180 | } 181 | 182 | const float* operator[](int i) const 183 | { 184 | return m_matrix[i]; 185 | } 186 | 187 | float m_matrix[3][4]; 188 | }; 189 | 190 | struct RGB 191 | { 192 | float R, G, B; 193 | }; 194 | 195 | #endif // !STRUCTS_H 196 | 197 | -------------------------------------------------------------------------------- /mhyprotPOC/Threads.cpp: -------------------------------------------------------------------------------- 1 | #include "Threads.h" 2 | #include "Database.h" 3 | #include 4 | #include 5 | #include 6 | #pragma comment(lib, "dwmapi.lib") 7 | 8 | 9 | 10 | static Vector3 RCSEx_vecOldAngle; 11 | static Vector3 RCSEx_vecViewAngle; 12 | static Vector3 RCSEx_vecFinalAngle; 13 | 14 | //Threads::Variables::Get().bActive 15 | static uintptr_t aimEntity = 0; 16 | int EntID = -1; 17 | float MinFov = 6000.f; 18 | bool lock = false; 19 | 20 | static int globalbone = 2; 21 | 22 | 23 | void RCS(Vector3 vecTargetViewAngle) 24 | { 25 | uintptr_t pLocalPlayer = ApexLegends::GetLocalPlayer(); 26 | if (pLocalPlayer) 27 | { 28 | Vector3 vecAimPunch = ApexLegends::GetLocalAimPunch(); 29 | if (GetAsyncKeyState(VK_LBUTTON)) 30 | { 31 | RCSEx_vecViewAngle.X = vecTargetViewAngle.X + RCSEx_vecOldAngle.X; 32 | RCSEx_vecViewAngle.Y = vecTargetViewAngle.Y + RCSEx_vecOldAngle.Y; 33 | RCSEx_vecFinalAngle.X = vecTargetViewAngle.X - (vecAimPunch.X); 34 | RCSEx_vecFinalAngle.Y = vecTargetViewAngle.Y - (vecAimPunch.Y); 35 | Vector3 vecFinalAngle = Maths::FinalizeAngle(RCSEx_vecFinalAngle); 36 | SetViewAngle(vecFinalAngle); 37 | RCSEx_vecOldAngle = RCSEx_vecFinalAngle; 38 | } 39 | else 40 | { 41 | RCSEx_vecOldAngle = { 0.0f, 0.0f, 0.0f }; 42 | } 43 | } 44 | } 45 | void FlushPlayerCache() 46 | { 47 | for (int i = 0; i < 60; i++) 48 | { 49 | APEXVars.visiblePlayerInfo[i] = 0.f; 50 | APEXVars.Visible[i] = false; 51 | APEXVars.EntityFov[i] = 0; 52 | } 53 | Sleep(5); 54 | 55 | } 56 | void Threads::Itemglow() 57 | { 58 | while (true) 59 | { 60 | if (CFG.bGlowItems) { 61 | uintptr_t pLocalPlayer = ApexLegends::GetLocalPlayer(); 62 | if (pLocalPlayer) 63 | { 64 | for (int i = 60; i <= 10000; i++) 65 | { 66 | uintptr_t pEntityBase = ApexLegends::GetEntityBase(i); 67 | if (pEntityBase) 68 | { 69 | if (ApexLegends::isEntityAnItem(pEntityBase)) { 70 | //printf("got here \n"); 71 | if (Maths::CalculateDistance(ApexLegends::GetEntityPosition(pLocalPlayer), ApexLegends::GetEntityPosition(pEntityBase)) < ((CFG.MaxDistance / 3) * 40)) 72 | ApexLegends::EnableItemGlow(pEntityBase); 73 | } 74 | } 75 | Sleep(1); 76 | } 77 | } 78 | } 79 | Sleep(2000); 80 | if (CFG.bRandomBones) 81 | { 82 | CFG.bone = CFG.BoneIds[(rand() % (5 - 1 + 1) + 1) - 1]; 83 | globalbone = CFG.bone; 84 | } 85 | } 86 | } 87 | uintptr_t GetBestAimEntity(uintptr_t pLocalPlayer) 88 | { 89 | MinFov = CFG.Fov; 90 | EntID = -1; 91 | for (int i = 0; i <= 60; i++) { 92 | 93 | if (CFG.bVischeck) 94 | { 95 | if (!APEXVars.Visible[i]) 96 | { 97 | continue; 98 | } 99 | } 100 | uintptr_t pEntity = ApexLegends::GetEntityBase(i); 101 | if (pEntity && ApexLegends::IsPlayer(pEntity) && !ApexLegends::isDowned(pEntity) && ApexLegends::IsAlive(pEntity) && ApexLegends::IsEnemy(pEntity)) { 102 | float flDistance = Maths::CalculateDistance(ApexLegends::GetEntityPosition(pLocalPlayer), ApexLegends::GetEntityPosition(pEntity)); 103 | if (flDistance > CFG.MaxDistance * 40) continue; 104 | Vector vecLocalBonePosition = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 105 | Vector vecEntityBonePositionFoV = ApexLegends::GetEntityBonePos(pEntity, 8); 106 | auto vecLocalViewAngle = ApexLegends::GetViewAngle(pLocalPlayer); 107 | float flCalculatedFov = Maths::GetFov(vecLocalViewAngle, Maths::FinalQAngle(Maths::CalcAngle(vecLocalBonePosition, vecEntityBonePositionFoV))); 108 | if (flCalculatedFov < MinFov) 109 | { 110 | 111 | MinFov = flCalculatedFov; 112 | EntID = i; 113 | } 114 | } 115 | } 116 | if (MinFov > CFG.Fov) return 0; 117 | if (EntID >= 0) 118 | return ApexLegends::GetEntityBase(EntID); 119 | return 0; 120 | } 121 | void Threads::ApexLegendsAimThread() 122 | { 123 | while (CFG.bActive) 124 | { 125 | if (CFG.bAimbot) { 126 | uintptr_t pLocalPlayer = ApexLegends::GetLocalPlayer(); 127 | if (pLocalPlayer) { 128 | if (GetAsyncKeyState(CFG.dwAimKey)) 129 | { 130 | uintptr_t pEnemy = GetBestAimEntity(pLocalPlayer); 131 | if (pEnemy != 0 && pEnemy != pLocalPlayer) 132 | { 133 | int LocalBone = CFG.bone; 134 | int id = EntID; 135 | float flDistance = Maths::CalculateDistance(ApexLegends::GetEntityPosition(pLocalPlayer), ApexLegends::GetEntityPosition(pEnemy)); 136 | if (flDistance > CFG.MaxDistance * 40) continue; 137 | float maxFOV = CFG.Fov; 138 | if (CFG.bClosestBone) 139 | { 140 | for (int i = 0; i < 100; i++) 141 | { 142 | auto vecLocalBonePosition = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 143 | Vector vecEntityBonePositionFoV = ApexLegends::GetEntityBonePos(pEnemy, i); 144 | auto vecLocalViewAngle = ApexLegends::GetViewAngle(pLocalPlayer); 145 | float flBoneFoV = Maths::GetFov(vecLocalViewAngle, Maths::FinalQAngle(Maths::CalcAngle(vecLocalBonePosition, vecEntityBonePositionFoV))); 146 | if (flBoneFoV < maxFOV) 147 | { 148 | maxFOV = flBoneFoV; 149 | LocalBone = i; 150 | } 151 | } 152 | } 153 | while (true) 154 | { 155 | Vector vecLocalBonePosition = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 156 | Vector vecEntityBonePositionFoV = ApexLegends::GetEntityBonePos(pEnemy, LocalBone); 157 | auto vecLocalViewAngle = ApexLegends::GetViewAngle(pLocalPlayer); 158 | float flCalculatedFov = Maths::GetFov(vecLocalViewAngle, Maths::FinalQAngle(Maths::CalcAngle(vecLocalBonePosition, vecEntityBonePositionFoV))); 159 | float localSmooth = CFG.flSmooth; 160 | if (flCalculatedFov > CFG.Fov) 161 | break; 162 | 163 | // ranged smooth 164 | // fov based smooth 165 | 166 | if (CFG.Safebot) 167 | { 168 | if (flCalculatedFov < (1 - ((flDistance / 100) / 10))) continue; 169 | } 170 | 171 | if (CFG.RandomizeSmoothness) 172 | { 173 | localSmooth = (CFG.MinSmooth + static_cast (rand()) / (static_cast (RAND_MAX / (CFG.flSmooth - CFG.MinSmooth)))) * 1.2; 174 | } 175 | if (CFG.DyanamicSmooth) 176 | { 177 | if (flCalculatedFov > 1) 178 | { 179 | localSmooth += 37.f; 180 | localSmooth = localSmooth / (flCalculatedFov / 4); 181 | } 182 | } 183 | if (CFG.bRandomBones) 184 | { 185 | LocalBone = globalbone; 186 | } 187 | auto absVelocity = ApexLegends::GetEntityAbsVelocity(pEnemy); 188 | absVelocity *= CFG.flSmooth / 40.f ; 189 | Vector vecVelocity = { absVelocity.X, absVelocity.Y, absVelocity.Z }; 190 | QAngle vecAimAngle = Maths::CalculatePredictionAngle(pLocalPlayer, ApexLegends::GetViewAngle(pLocalPlayer), ApexLegends::GetEntitySwayAngle(pLocalPlayer), ApexLegends::GetEntityBonePos(pEnemy, LocalBone), vecVelocity, localSmooth * 17.f ); 191 | if (vecAimAngle.x != 0 && vecAimAngle.y != 0) 192 | { 193 | ApexLegends::SetViewQAngle(vecAimAngle); 194 | } 195 | if (!GetAsyncKeyState(CFG.dwAimKey)) { 196 | FlushPlayerCache(); 197 | break; 198 | } 199 | if (CFG.bVischeck) 200 | { 201 | if (!APEXVars.Visible[id]) 202 | { 203 | FlushPlayerCache(); 204 | break; 205 | } 206 | } 207 | } 208 | //Sleep(100); 209 | } 210 | } 211 | else if (GetAsyncKeyState(VK_LBUTTON) && CFG.bLeftClickAim) 212 | { 213 | uintptr_t pEnemy = GetBestAimEntity(pLocalPlayer); 214 | if (pEnemy != 0 && pEnemy != pLocalPlayer) 215 | { 216 | int LocalBone = CFG.bone; 217 | int id = EntID; 218 | float flDistance = Maths::CalculateDistance(ApexLegends::GetEntityPosition(pLocalPlayer), ApexLegends::GetEntityPosition(pEnemy)); 219 | if (flDistance > CFG.MaxDistance * 40) continue; 220 | float maxFOV = CFG.Fov; 221 | if (CFG.bClosestBone) 222 | { 223 | for (int i = 0; i < 100; i++) 224 | { 225 | auto vecLocalBonePosition = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 226 | Vector vecEntityBonePositionFoV = ApexLegends::GetEntityBonePos(pEnemy, i); 227 | auto vecLocalViewAngle = ApexLegends::GetViewAngle(pLocalPlayer); 228 | float flBoneFoV = Maths::GetFov(vecLocalViewAngle, Maths::CalcAngle(vecLocalBonePosition, vecEntityBonePositionFoV)); 229 | if (flBoneFoV < maxFOV) 230 | { 231 | maxFOV = flBoneFoV; 232 | LocalBone = i; 233 | } 234 | } 235 | } 236 | while (true) 237 | { 238 | Vector vecLocalBonePosition = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 239 | Vector vecEntityBonePositionFoV = ApexLegends::GetEntityBonePos(pEnemy, LocalBone); 240 | auto vecLocalViewAngle = ApexLegends::GetViewAngle(pLocalPlayer); 241 | float flCalculatedFov = Maths::GetFov(vecLocalViewAngle, Maths::CalcAngle(vecLocalBonePosition, vecEntityBonePositionFoV)); 242 | float localSmooth = CFG.flSmooth; 243 | if (flCalculatedFov > CFG.Fov) 244 | break; 245 | // ranged smooth 246 | // fov based smooth 247 | if (CFG.Safebot) 248 | { 249 | if (flCalculatedFov < (1 - ((flDistance / 100) / 10))) continue; 250 | } 251 | 252 | if (CFG.RandomizeSmoothness) 253 | { 254 | localSmooth = (CFG.MinSmooth + static_cast (rand()) / (static_cast (RAND_MAX / (CFG.flSmooth - CFG.MinSmooth)))) * 1.2; 255 | } 256 | if (CFG.DyanamicSmooth) 257 | { 258 | if (flCalculatedFov > 1) 259 | { 260 | localSmooth += 37.f; 261 | localSmooth = localSmooth / (flCalculatedFov / 4); 262 | } 263 | } 264 | if (CFG.bRandomBones) 265 | { 266 | LocalBone = globalbone; 267 | } 268 | auto absVelocity = ApexLegends::GetEntityAbsVelocity(pEnemy); 269 | absVelocity *= CFG.flSmooth / 40.f; 270 | Vector vecVelocity = { absVelocity.X, absVelocity.Y, absVelocity.Z }; 271 | QAngle vecAimAngle = Maths::CalculatePredictionAngle(pLocalPlayer, ApexLegends::GetViewAngle(pLocalPlayer), ApexLegends::GetEntitySwayAngle(pLocalPlayer), ApexLegends::GetEntityBonePos(pEnemy, CFG.bone), vecVelocity, localSmooth * 17.f); 272 | if (vecAimAngle.x != 0 && vecAimAngle.y != 0) 273 | { 274 | 275 | //vecAimAngle.x = static_cast(vecAimAngle.x); 276 | //vecAimAngle.y = static_cast(vecAimAngle.y); 277 | ApexLegends::SetViewQAngle(vecAimAngle); 278 | } 279 | if (!GetAsyncKeyState(VK_LBUTTON)) 280 | { 281 | //FlushPlayerCache(); 282 | break; 283 | } 284 | if (CFG.bVischeck) 285 | { 286 | if (!APEXVars.Visible[id]) 287 | { 288 | // FlushPlayerCache(); 289 | break; 290 | } 291 | } 292 | } 293 | //Sleep(100); 294 | } 295 | } 296 | } 297 | 298 | } 299 | Sleep(1); 300 | } 301 | } 302 | 303 | void Threads::Glow() 304 | { 305 | while (true) 306 | { 307 | uintptr_t pLocalPlayer = ApexLegends::GetLocalPlayer(); 308 | MinFov = CFG.Fov; 309 | EntID = -1; 310 | if (pLocalPlayer) { 311 | for (int i = 0; i <= 60; i++) 312 | { 313 | 314 | APEXVars.EntityFov[i] = 900.f; 315 | uintptr_t pEntityBase = ApexLegends::GetEntityBase(i); 316 | double flCurrentVisTime = -1.f; 317 | 318 | if (pEntityBase && pEntityBase != NULL) 319 | { 320 | if ((pEntityBase == pLocalPlayer)) 321 | { 322 | APEXVars.localname = ApexLegends::GetPlayerName(i); 323 | //printf("LocalName : %s \n",APEXVars.localname); 324 | } 325 | APEXVars.PlayerNames[i] = ApexLegends::GetPlayerName(i); 326 | if (ApexLegends::IsPlayer(pEntityBase)) 327 | { 328 | bool isEnemy = ApexLegends::IsEnemy(pEntityBase); 329 | if (isEnemy) { 330 | if (Maths::CalculateDistance(ApexLegends::GetEntityPosition(pLocalPlayer), ApexLegends::GetEntityPosition(pEntityBase)) < (CFG.MaxDistance * 40.f)) { 331 | if (CFG.bGlowPlayers) 332 | ApexLegends::GlowESP(pEntityBase); 333 | } 334 | } 335 | if (pEntityBase == pLocalPlayer || !isEnemy || !ApexLegends::IsAlive(pEntityBase)) { 336 | APEXVars.EntityFov[i] = 999.f; 337 | APEXVars.Visible[i] = false; 338 | continue; 339 | } 340 | 341 | // IF ENTITY IS NOT TEAMMATE AND NOT LOCALPLAYER 342 | flCurrentVisTime = ApexLegends::LastVisibleTime(pEntityBase); 343 | if (flCurrentVisTime > APEXVars.visiblePlayerInfo[i] || flCurrentVisTime < 0.f && APEXVars.visiblePlayerInfo[i] > 0.f) 344 | { 345 | APEXVars.Visible[i] = true; 346 | } 347 | else 348 | { 349 | APEXVars.Visible[i] = false; 350 | } 351 | APEXVars.PlayersHealth[i] = Memory::ReadProcessMemory(APEXVars.dwProcessId,pEntityBase + APEXOffsets.OFFSET_HEALTH); 352 | APEXVars.PlayersArmor[i] = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_SHIELD); 353 | APEXVars.MaxPlayerArmor[i] = Memory::ReadProcessMemory(APEXVars.dwProcessId, pEntityBase + APEXOffsets.OFFSET_MAX_SHIELD); 354 | Vector vecLocalBonePosition = ApexLegends::GetEntityBonePos(pLocalPlayer, 8); 355 | Vector vecEntityBonePositionFoV = ApexLegends::GetEntityBonePos(pEntityBase, 8); 356 | auto vecLocalViewAngle = ApexLegends::GetViewAngle(pLocalPlayer); 357 | float flCalculatedFov = Maths::GetFov(vecLocalViewAngle, Maths::FinalQAngle(Maths::CalcAngle(vecLocalBonePosition, vecEntityBonePositionFoV))); 358 | APEXVars.EntityFov[i] = flCalculatedFov; 359 | } 360 | } 361 | // Sleep(1); 362 | APEXVars.visiblePlayerInfo[i] = flCurrentVisTime; 363 | } 364 | } 365 | Sleep(50); 366 | 367 | } 368 | } 369 | 370 | -------------------------------------------------------------------------------- /mhyprotPOC/Threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Maths.h" 4 | #include "Singleton.h" 5 | #include "ApexLegends.h" 6 | #include "Overlay.h" 7 | #include "CFG.h" 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | 14 | namespace Threads 15 | { 16 | class Variables : public Singleton 17 | { 18 | public: 19 | thread thApexLegendsThread; 20 | thread ItemGlowthread; 21 | thread tempPlayerGlow; 22 | }; 23 | #define ThreadVars Threads::Variables::Get() 24 | void Glow(); 25 | void ApexLegendsAimThread(); 26 | void Itemglow(); 27 | void CRC(); 28 | } 29 | -------------------------------------------------------------------------------- /mhyprotPOC/Utilities.cpp: -------------------------------------------------------------------------------- 1 | #include "Utilities.h" 2 | 3 | bool Driver::CreateFileFromMemory(const std::string& strDesiredFilePath, const char* chAddress, size_t szSize) 4 | { 5 | std::ofstream file_ofstream(strDesiredFilePath.c_str(), std::ios_base::out | std::ios_base::binary); 6 | if (!file_ofstream.write(chAddress, szSize)) 7 | { 8 | file_ofstream.close(); 9 | return false; 10 | } 11 | file_ofstream.close(); 12 | return true; 13 | } 14 | void Utilities::GetDesktopResolution(int& horizontal, int& vertical) 15 | { 16 | RECT desktop; 17 | const HWND hDesktop = GetDesktopWindow(); 18 | GetWindowRect(hDesktop, &desktop); 19 | horizontal = desktop.right; 20 | vertical = desktop.bottom; 21 | } 22 | 23 | 24 | bool Driver::DeleteDriverFile(const char* chDriverDirectory) 25 | { 26 | return DeleteFileA(chDriverDirectory); 27 | } 28 | 29 | bool Driver::CreateAndStartDriverService(const char* chServiceName, const char* chDriverDirectory) 30 | { 31 | SC_HANDLE hSCM = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE); 32 | if (hSCM) 33 | { 34 | SC_HANDLE hService = CreateServiceA(hSCM, chServiceName, chServiceName, SERVICE_START | SERVICE_STOP | DELETE, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, chDriverDirectory, nullptr, nullptr, nullptr, nullptr, nullptr); 35 | if (!hService) 36 | { 37 | hService = OpenServiceA(hSCM, chServiceName, SERVICE_START); 38 | if (!hService) 39 | { 40 | CloseServiceHandle(hService); 41 | return false; 42 | } 43 | } 44 | bool bResult = StartService(hService, 0, nullptr); 45 | CloseServiceHandle(hSCM); 46 | CloseServiceHandle(hService); 47 | return bResult; 48 | } 49 | return false; 50 | } 51 | 52 | bool Driver::StopAndDeleteDriverService(const char* chServiceName, const char* chDriverDirectory) 53 | { 54 | SC_HANDLE hSCM = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE); 55 | if (!hSCM) 56 | { 57 | return false; 58 | } 59 | SC_HANDLE hService = OpenServiceA(hSCM, chServiceName, SERVICE_STOP | DELETE); 60 | if (!hService) 61 | { 62 | CloseServiceHandle(hSCM); 63 | return false; 64 | } 65 | SERVICE_STATUS sStatus = { 0 }; 66 | bool bResult = ControlService(hService, SERVICE_CONTROL_STOP, &sStatus) && DeleteService(hService); 67 | CloseServiceHandle(hService); 68 | CloseServiceHandle(hSCM); 69 | Sleep(2000); 70 | return DeleteDriverFile(chDriverDirectory) && bResult; 71 | } 72 | 73 | bool Driver::ServiceIsRunning(const char* chServiceName) 74 | { 75 | SC_HANDLE hSCM = OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS); 76 | if (hSCM) 77 | { 78 | SC_HANDLE hService = OpenServiceA(hSCM, chServiceName, SERVICE_ALL_ACCESS); 79 | if (hService) 80 | { 81 | CloseServiceHandle(hSCM); 82 | CloseServiceHandle(hService); 83 | return true; 84 | } 85 | } 86 | return false; 87 | } 88 | 89 | void Driver::StopAndDeleteAllDrivers() 90 | { 91 | if (Driver::ServiceIsRunning(Driver::chMhyprotDriverServiceName)) 92 | { 93 | Driver::StopAndDeleteDriverService(Driver::chMhyprotDriverServiceName, Driver::chMhyprotDriverDirectory); 94 | } 95 | if (Driver::ServiceIsRunning(Driver::chGACDriverServiceName)) 96 | { 97 | Driver::StopAndDeleteDriverService(Driver::chGACDriverServiceName, Driver::chGACDriverDirectory); 98 | } 99 | } 100 | 101 | PCHAR Utilities::MD5(PCHAR chText) 102 | { 103 | static char chResult[33]; 104 | RtlZeroMemory(chResult, sizeof(chResult)); 105 | md5_state_t md5State; 106 | md5_byte_t md5Sum[16]; 107 | md5_init(&md5State); 108 | md5_append(&md5State, (const md5_byte_t*)chText, strlen(chText)); 109 | md5_finish(&md5State, md5Sum); 110 | httpMD5String(md5Sum, chResult); 111 | return chResult; 112 | } 113 | 114 | string Utilities::StrReplace(std::string str, const std::string& from, const std::string& to) 115 | { 116 | size_t start_pos = str.find(from); 117 | if (start_pos == std::string::npos) 118 | { 119 | return str; 120 | } 121 | str.replace(start_pos, from.length(), to); 122 | return str; 123 | } 124 | 125 | bool Utilities::ReadFileToMemory(const std::string& strFilePath, std::vector* pOutBuffer) 126 | { 127 | std::ifstream file_ifstream(strFilePath, std::ios::binary); 128 | if (!file_ifstream) 129 | { 130 | return false; 131 | } 132 | pOutBuffer->assign((std::istreambuf_iterator(file_ifstream)), std::istreambuf_iterator()); 133 | file_ifstream.close(); 134 | return true; 135 | } 136 | 137 | bool Utilities::ConvertFileToByteArray(const char* chFileName, const char* chFileDestination) 138 | { 139 | vector raw_image = { 0 }; 140 | if (ReadFileToMemory(chFileName, &raw_image)) 141 | { 142 | ofstream myfile; 143 | myfile.open(chFileDestination); 144 | for (int i = 0; i < +raw_image.size(); i++) 145 | { 146 | myfile << "0x" << hex << uppercase << +raw_image[i] << ", "; 147 | } 148 | return true; 149 | myfile.close(); 150 | } 151 | else 152 | { 153 | return false; 154 | } 155 | } 156 | 157 | bool Utilities::UpdateEPROCESSOffsets() 158 | { 159 | OSVERSIONINFOEXW osVersionInfo = Utilities::GetOSVersionInfo(); 160 | if (osVersionInfo.dwBuildNumber == 10240) 161 | { 162 | UtilVars.pImageFileNameOffset = 0x448; 163 | UtilVars.pUniqueProcessIdOffset = 0x2E8; 164 | UtilVars.pSectionBaseOffset = 0x3C0; 165 | UtilVars.pActiveProcessLinkOffset = 0x2F0; 166 | UtilVars.pPEBOffset = 0x3F8; 167 | return true; 168 | } 169 | else if (osVersionInfo.dwBuildNumber == 10586) 170 | { 171 | UtilVars.pImageFileNameOffset = 0x450; 172 | UtilVars.pUniqueProcessIdOffset = 0x2E8; 173 | UtilVars.pSectionBaseOffset = 0x3C0; 174 | UtilVars.pActiveProcessLinkOffset = 0x2F0; 175 | UtilVars.pPEBOffset = 0x3F8; 176 | return true; 177 | } 178 | else if (osVersionInfo.dwBuildNumber == 14393) 179 | { 180 | UtilVars.pImageFileNameOffset = 0x450; 181 | UtilVars.pUniqueProcessIdOffset = 0x2E8; 182 | UtilVars.pSectionBaseOffset = 0x3C0; 183 | UtilVars.pActiveProcessLinkOffset = 0x2F0; 184 | UtilVars.pPEBOffset = 0x3F8; 185 | return true; 186 | } 187 | else if (osVersionInfo.dwBuildNumber == 15063) 188 | { 189 | UtilVars.pImageFileNameOffset = 0x450; 190 | UtilVars.pUniqueProcessIdOffset = 0x2E0; 191 | UtilVars.pSectionBaseOffset = 0x3C0; 192 | UtilVars.pActiveProcessLinkOffset = 0x2E8; 193 | UtilVars.pPEBOffset = 0x3F8; 194 | return true; 195 | } 196 | else if (osVersionInfo.dwBuildNumber == 16299) 197 | { 198 | UtilVars.pImageFileNameOffset = 0x450; 199 | UtilVars.pUniqueProcessIdOffset = 0x2E0; 200 | UtilVars.pSectionBaseOffset = 0x3C0; 201 | UtilVars.pActiveProcessLinkOffset = 0x2E8; 202 | UtilVars.pPEBOffset = 0x3F8; 203 | return true; 204 | } 205 | else if (osVersionInfo.dwBuildNumber == 17134) 206 | { 207 | UtilVars.pImageFileNameOffset = 0x450; 208 | UtilVars.pUniqueProcessIdOffset = 0x2E0; 209 | UtilVars.pSectionBaseOffset = 0x3C0; 210 | UtilVars.pActiveProcessLinkOffset = 0x2E8; 211 | UtilVars.pPEBOffset = 0x3F8; 212 | return true; 213 | } 214 | else if (osVersionInfo.dwBuildNumber == 17763) 215 | { 216 | UtilVars.pImageFileNameOffset = 0x450; 217 | UtilVars.pUniqueProcessIdOffset = 0x2E0; 218 | UtilVars.pSectionBaseOffset = 0x3C0; 219 | UtilVars.pActiveProcessLinkOffset = 0x2E8; 220 | UtilVars.pPEBOffset = 0x3F8; 221 | return true; 222 | } 223 | else if (osVersionInfo.dwBuildNumber == 18362) 224 | { 225 | UtilVars.pImageFileNameOffset = 0x450; 226 | UtilVars.pUniqueProcessIdOffset = 0x2E8; 227 | UtilVars.pSectionBaseOffset = 0x3C8; 228 | UtilVars.pActiveProcessLinkOffset = 0x2F0; 229 | UtilVars.pPEBOffset = 0x3F8; 230 | return true; 231 | } 232 | else if (osVersionInfo.dwBuildNumber == 18363) 233 | { 234 | UtilVars.pImageFileNameOffset = 0x450; 235 | UtilVars.pUniqueProcessIdOffset = 0x2E8; 236 | UtilVars.pSectionBaseOffset = 0x3C8; 237 | UtilVars.pActiveProcessLinkOffset = 0x2F0; 238 | UtilVars.pPEBOffset = 0x3F8; 239 | return true; 240 | } 241 | else if (osVersionInfo.dwBuildNumber == 19041) 242 | { 243 | UtilVars.pImageFileNameOffset = 0x5A8; 244 | UtilVars.pUniqueProcessIdOffset = 0x440; 245 | UtilVars.pSectionBaseOffset = 0x520; 246 | UtilVars.pActiveProcessLinkOffset = 0x448; 247 | UtilVars.pPEBOffset = 0x550; 248 | return true; 249 | } 250 | else if (osVersionInfo.dwBuildNumber == 19042) 251 | { 252 | UtilVars.pImageFileNameOffset = 0x5A8; 253 | UtilVars.pUniqueProcessIdOffset = 0x440; 254 | UtilVars.pSectionBaseOffset = 0x520; 255 | UtilVars.pActiveProcessLinkOffset = 0x448; 256 | UtilVars.pPEBOffset = 0x550; 257 | return true; 258 | } 259 | else if (osVersionInfo.dwBuildNumber == 19043) 260 | { 261 | UtilVars.pImageFileNameOffset = 0x5A8; 262 | UtilVars.pUniqueProcessIdOffset = 0x440; 263 | UtilVars.pSectionBaseOffset = 0x520; 264 | UtilVars.pActiveProcessLinkOffset = 0x448; 265 | UtilVars.pPEBOffset = 0x550; 266 | return true; 267 | } 268 | return false; 269 | } 270 | 271 | uintptr_t Utilities::TranslateLinearAddress(uint64_t pDirectoryTableBaseAddress, uint64_t pVirtualAddress) 272 | { 273 | uint16_t PML4 = (uint16_t)((pVirtualAddress >> 39) & 0x1FF); 274 | uint16_t pDirectoryPtr = (uint16_t)((pVirtualAddress >> 30) & 0x1FF); 275 | uint16_t pDirectory = (uint16_t)((pVirtualAddress >> 21) & 0x1FF); 276 | uint16_t pTable = (uint16_t)((pVirtualAddress >> 12) & 0x1FF); 277 | uint64_t PML4E = 0; 278 | Memory::ReadVirtualMemory(pDirectoryTableBaseAddress + (uint64_t)PML4 * sizeof(uint64_t), (uint8_t*)&PML4E, sizeof(PML4E)); 279 | if (PML4E) 280 | { 281 | uint64_t PDPTE = 0; 282 | Memory::ReadVirtualMemory((PML4E & 0xFFFF1FFFFFF000) + (uint64_t)pDirectoryPtr * sizeof(uint64_t), (uint8_t*)&PDPTE, sizeof(PDPTE)); 283 | if (PDPTE) 284 | { 285 | if ((PDPTE & (1 << 7)) != 0) 286 | { 287 | return (PDPTE & 0xFFFFFC0000000) + (pVirtualAddress & 0x3FFFFFFF); 288 | } 289 | uint64_t PDE = 0; 290 | Memory::ReadVirtualMemory((PDPTE & 0xFFFFFFFFFF000) + (uint64_t)pDirectory * sizeof(uint64_t), (uint8_t*)&PDE, sizeof(PDE)); 291 | if (PDE) 292 | { 293 | if ((PDE & (1 << 7)) != 0) 294 | { 295 | return (PDE & 0xFFFFFFFE00000) + (pVirtualAddress & 0x1FFFFF); 296 | } 297 | uint64_t PTE = 0; 298 | Memory::ReadVirtualMemory((PDE & 0xFFFFFFFFFF000) + (uint64_t)pTable * sizeof(uint64_t), (uint8_t*)&PTE, sizeof(PTE)); 299 | if (PTE) 300 | { 301 | return (PTE & 0xFFFFFFFFFF000) + (pVirtualAddress & 0xFFF); 302 | } 303 | } 304 | } 305 | } 306 | return (uintptr_t)0; 307 | } 308 | 309 | uintptr_t Utilities::SFGetEPROCESS(int dwProcessId) 310 | { 311 | auto pHandleInfo = QueryInfo(SystemHandleInformation); 312 | if (pHandleInfo.get()) 313 | { 314 | for (size_t i = 0; i < pHandleInfo->HandleCount; i++) 315 | { 316 | if (dwProcessId == pHandleInfo->Handles[i].ProcessId && 7 == pHandleInfo->Handles[i].ObjectTypeNumber) 317 | { 318 | return reinterpret_cast(pHandleInfo->Handles[i].Object); 319 | } 320 | } 321 | } 322 | return 0; 323 | } 324 | 325 | uintptr_t Utilities::GetEPROCESS(int dwProcessId) 326 | { 327 | _LIST_ENTRY pActiveProcessLinks; 328 | Memory::ReadVirtualMemory(SFGetEPROCESS(4) + UtilVars.pActiveProcessLinkOffset, (uint8_t*)&pActiveProcessLinks, sizeof(pActiveProcessLinks)); 329 | if (&pActiveProcessLinks) 330 | { 331 | while (true) 332 | { 333 | uint64_t pNextPid = 0; 334 | uint64_t pNextLink = (uint64_t)(pActiveProcessLinks.Flink); 335 | uint64_t pNext = pNextLink - UtilVars.pActiveProcessLinkOffset; 336 | if (pNext) 337 | { 338 | Memory::ReadVirtualMemory(pNext + UtilVars.pUniqueProcessIdOffset, (uint8_t*)&pNextPid, sizeof(pNextPid)); 339 | Memory::ReadVirtualMemory(pNext + UtilVars.pActiveProcessLinkOffset, (uint8_t*)&pActiveProcessLinks, sizeof(pActiveProcessLinks)); 340 | if (pNextPid == dwProcessId) 341 | { 342 | return pNext; 343 | } 344 | if (pNextPid == 4 || pNextPid == 0) 345 | { 346 | break; 347 | } 348 | } 349 | } 350 | } 351 | return 0; 352 | } 353 | 354 | uintptr_t Utilities::GetKernelModuleAddress(const std::string& strModuleName) 355 | { 356 | void* pBuffer = nullptr; 357 | DWORD dwBufferSize = 0; 358 | NTSTATUS ntStatus = NtQuerySystemInformation(static_cast(SystemModuleInformation), pBuffer, dwBufferSize, &dwBufferSize); 359 | while (ntStatus == STATUS_INFO_LENGTH_MISMATCH) 360 | { 361 | VirtualFree(pBuffer, 0, MEM_RELEASE); 362 | pBuffer = VirtualAlloc(nullptr, dwBufferSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); 363 | ntStatus = NtQuerySystemInformation(static_cast(SystemModuleInformation), pBuffer, dwBufferSize, &dwBufferSize); 364 | } 365 | if (!NT_SUCCESS(ntStatus)) 366 | { 367 | VirtualFree(pBuffer, 0, MEM_RELEASE); 368 | return 0; 369 | } 370 | PRTL_PROCESS_MODULES pModules = static_cast(pBuffer); 371 | for (auto i = 0u; i < pModules->NumberOfModules; ++i) 372 | { 373 | const std::string strCurrentModuleName = std::string(reinterpret_cast(pModules->Modules[i].FullPathName) + pModules->Modules[i].OffsetToFileName); 374 | if (!_stricmp(strCurrentModuleName.c_str(), strModuleName.c_str())) 375 | { 376 | const uintptr_t pResult = reinterpret_cast(pModules->Modules[i].ImageBase); 377 | VirtualFree(pBuffer, 0, MEM_RELEASE); 378 | return pResult; 379 | } 380 | } 381 | VirtualFree(pBuffer, 0, MEM_RELEASE); 382 | return 0; 383 | } 384 | 385 | uintptr_t Utilities::GetProcessBaseAddress(int dwProcessId) 386 | { 387 | if (dwProcessId == 0) 388 | { 389 | dwProcessId = GetKernelModuleAddress("ntoskrnl.exe"); 390 | } 391 | uintptr_t pEPROCESS = GetEPROCESS(dwProcessId); 392 | uintptr_t pBaseAddress = 0; 393 | if (pEPROCESS) 394 | { 395 | Memory::ReadVirtualMemory(pEPROCESS + UtilVars.pSectionBaseOffset, (uint8_t*)&pBaseAddress, sizeof(pBaseAddress)); 396 | return pBaseAddress; 397 | } 398 | return 0; 399 | } 400 | 401 | DWORD Utilities::GetProcessIdByName(const wchar_t* wcProcessName) 402 | { 403 | PROCESSENTRY32 processEntry32; 404 | processEntry32.dwSize = sizeof(PROCESSENTRY32); 405 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); 406 | if (Process32First(hSnapshot, &processEntry32) == TRUE) 407 | { 408 | while (Process32Next(hSnapshot, &processEntry32) == TRUE) 409 | { 410 | if (wcscmp(processEntry32.szExeFile, wcProcessName) == 0) 411 | { 412 | return processEntry32.th32ProcessID; 413 | } 414 | } 415 | } 416 | CloseHandle(hSnapshot); 417 | return 0; 418 | } 419 | 420 | DWORD Utilities::GetProcessIdByContainingString(const wchar_t* wcProcessName) 421 | { 422 | PROCESSENTRY32 processEntry32; 423 | processEntry32.dwSize = sizeof(PROCESSENTRY32); 424 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); 425 | if (Process32First(hSnapshot, &processEntry32) == TRUE) 426 | { 427 | while (Process32Next(hSnapshot, &processEntry32) == TRUE) 428 | { 429 | if (wcsstr(processEntry32.szExeFile, wcProcessName) != 0) 430 | { 431 | return processEntry32.th32ProcessID; 432 | } 433 | } 434 | } 435 | CloseHandle(hSnapshot); 436 | return 0; 437 | } 438 | 439 | bool Utilities::IsProcessBeingDebugged64(int dwProcessId) 440 | { 441 | uintptr_t pPEB = Memory::ReadVirtualMemory(GetEPROCESS(dwProcessId) + UtilVars.pPEBOffset); 442 | if (pPEB) 443 | { 444 | UCHAR ucBeingDebugged = Memory::ReadProcessMemory(dwProcessId, pPEB + 0x2); 445 | return (ucBeingDebugged == (UCHAR)1) || (IsDebuggerPresent()); 446 | } 447 | return false; 448 | } 449 | 450 | ULONG Utilities::GetModuleBaseAddress32(int dwProcessId, const wchar_t* wcModuleName, DWORD* pdwSize, DWORD dwMaxCount) 451 | { 452 | /* 453 | * TODO : 454 | * Fix the unlimited loop using actual method instead of cringy max count 455 | * Refactor 456 | */ 457 | uintptr_t pPEB = Memory::ReadVirtualMemory(GetEPROCESS(dwProcessId) + UtilVars.pPEBOffset); 458 | if (pPEB) 459 | { 460 | uintptr_t pPEB32Ptr = pPEB + 0x1000; 461 | PEB32 pPEB32 = Memory::ReadProcessMemory(dwProcessId, pPEB32Ptr); 462 | if (&pPEB32) 463 | { 464 | PEB_LDR_DATA32 pPEBLDRData32 = Memory::ReadProcessMemory(dwProcessId, pPEB32.Ldr); 465 | if (&pPEBLDRData32) 466 | { 467 | ULONG pListHead = pPEB32.Ldr + 0x10; 468 | UCHAR ucImageName[8000]; 469 | static int dwCount = 0; 470 | for (ULONG pCurrentList = pPEBLDRData32.InLoadOrderModuleList.Flink; pCurrentList != pListHead;) 471 | { 472 | LDR_DATA_TABLE_ENTRY32 pEntryData = Memory::ReadProcessMemory(dwProcessId, pCurrentList); 473 | if (&pEntryData) 474 | { 475 | ULONG ulImageNamePtr = Memory::ReadProcessMemory(dwProcessId, pCurrentList + 0x30); 476 | Memory::ReadProcessMemory(dwProcessId, ulImageNamePtr, &ucImageName, 128); 477 | wchar_t* wcImageName = reinterpret_cast(ucImageName); 478 | if (wcscmp(wcImageName, wcModuleName) == 0) 479 | { 480 | if (pdwSize != nullptr) 481 | *pdwSize = (DWORD)pEntryData.SizeOfImage; 482 | return pEntryData.DllBase; 483 | } 484 | pCurrentList = (ULONG)pEntryData.InLoadOrderLinks.Flink; 485 | dwCount += 1; 486 | if (dwCount >= dwMaxCount) 487 | break; 488 | } 489 | } 490 | } 491 | } 492 | } 493 | return 0; 494 | } 495 | 496 | uintptr_t Utilities::GetModuleBaseAddress64(int dwProcessId, const wchar_t* wcModuleName, DWORD* pdwSize) 497 | { 498 | /* 499 | * TODO : 500 | * Read the actual struct instead of pointer 501 | * Refactor 502 | */ 503 | uintptr_t pPEB = Memory::ReadVirtualMemory(GetEPROCESS(dwProcessId) + UtilVars.pPEBOffset); 504 | if (pPEB) 505 | { 506 | uintptr_t pLDRData = Memory::ReadProcessMemory(dwProcessId, pPEB + 0x18); 507 | if (pLDRData) 508 | { 509 | uintptr_t pListHead = pLDRData + 0x10; 510 | uintptr_t InLoadOrderModuleList = Memory::ReadProcessMemory(dwProcessId, pLDRData + 0x10); 511 | if (InLoadOrderModuleList) 512 | { 513 | UCHAR ucImageName[8000]; 514 | static int dwCount = 0; 515 | for (uintptr_t pCurrentList = InLoadOrderModuleList; pCurrentList != pListHead;) 516 | { 517 | LDR_DATA_TABLE_ENTRY pEntryData = Memory::ReadProcessMemory(dwProcessId, pCurrentList); 518 | if (&pEntryData) 519 | { 520 | uintptr_t pImageNamePtr = Memory::ReadProcessMemory(dwProcessId, pCurrentList + 0x60); 521 | if (pImageNamePtr) 522 | { 523 | Memory::ReadProcessMemory(dwProcessId, pImageNamePtr, &ucImageName, 128); 524 | wchar_t* wcImageName = reinterpret_cast(ucImageName); 525 | if (wcscmp(wcImageName, wcModuleName) == 0) 526 | { 527 | if (pdwSize != nullptr) 528 | *pdwSize = (DWORD)pEntryData.SizeOfImage; 529 | return (uintptr_t)pEntryData.DllBase; 530 | } 531 | pCurrentList = (uintptr_t)pEntryData.InLoadOrderLinks.Flink; 532 | dwCount += 1; 533 | } 534 | } 535 | } 536 | } 537 | } 538 | } 539 | return 0; 540 | } 541 | 542 | uintptr_t Utilities::SearchSignature(DWORD dwProcessId, uintptr_t pStartAddress, SIZE_T szLength, BYTE* bPattern, const char* chMask) 543 | { 544 | SIZE_T szPos = 0; 545 | auto maskLength = strlen(chMask) - 1; 546 | auto startAdress = pStartAddress; 547 | for (auto i = startAdress; i < startAdress + szLength; ++i) 548 | { 549 | if (Memory::ReadProcessMemory(dwProcessId, i) == bPattern[szPos] || chMask[szPos] == '?') 550 | { 551 | if (chMask[szPos + 1] == '\0') 552 | { 553 | return i - maskLength; 554 | } 555 | szPos++; 556 | } 557 | else 558 | { 559 | szPos = 0; 560 | } 561 | } 562 | return 0; 563 | } 564 | 565 | uintptr_t Utilities::FindPattern(DWORD dwProcessId, uintptr_t pModuleAddress, SIZE_T szModuleSize, BYTE* bPattern, const char* chMask) 566 | { 567 | return SearchSignature(dwProcessId, pModuleAddress, szModuleSize, bPattern, chMask); 568 | } 569 | 570 | uintptr_t Utilities::ExtractOffsetByPattern(DWORD dwProcessId, uintptr_t pModuleAddress, SIZE_T szModuleSize, ULONG ulAdditionalOffset, ULONG ulExtra, const char* chPattern, const char* chMask, BOOLEAN bRelative) 571 | { 572 | bool bStatus = true; 573 | uintptr_t pResult = FindPattern(dwProcessId, pModuleAddress, szModuleSize, (BYTE*)chPattern, chMask); 574 | if (ulAdditionalOffset != NULL && pResult) 575 | { 576 | bStatus = Memory::ReadProcessMemory(dwProcessId, (uint64_t)(pResult + ulAdditionalOffset), &pResult, sizeof(pResult)); 577 | } 578 | if (bStatus && pResult) 579 | { 580 | pResult += ulExtra; 581 | if (bRelative) 582 | { 583 | pResult -= pModuleAddress; 584 | } 585 | return pResult; 586 | } 587 | else 588 | { 589 | return 0; 590 | } 591 | } 592 | 593 | OSVERSIONINFOEXW Utilities::GetOSVersionInfo() 594 | { 595 | NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW); 596 | OSVERSIONINFOEXW osInfo; 597 | *(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion"); 598 | if (RtlGetVersion != NULL) 599 | { 600 | osInfo.dwOSVersionInfoSize = sizeof(osInfo); 601 | RtlGetVersion(&osInfo); 602 | return osInfo; 603 | } 604 | } -------------------------------------------------------------------------------- /mhyprotPOC/Utilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MD5.h" 4 | #include "Memory.h" 5 | #include "Singleton.h" 6 | #include "KeStructs.h" 7 | #include "GAC_Driver.h" 8 | #include "mhyprot_Driver.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define INRANGE(x,a,b) (x >= a && x <= b) 15 | #define GET_BYTE( x ) (GET_BITS(x[0]) << 4 | GET_BITS(x[1])) 16 | #define GET_BITS( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0)) 17 | #define getBits( x ) (INRANGE(x,'0','9') ? (x - '0') : ((x&(~0x20)) - 'A' + 0xa)) 18 | #define getByte( x ) (getBits(x[0]) << 4 | getBits(x[1])) 19 | 20 | using namespace std; 21 | 22 | namespace Driver 23 | { 24 | static const char* chMhyprotDriverDirectory = "C:/Windows/system32/drivers/mhyprot2.sys"; 25 | static const char* chMhyprotDriverServiceName = "mhyprot2"; 26 | static const char* chGACDriverDirectory = "C:/Windows/system32/drivers/GAC_DE.sys"; 27 | static const char* chGACDriverServiceName = "GAC_DE"; 28 | 29 | bool CreateFileFromMemory(const std::string& strDesiredFilePath, const char* chAddress, size_t szSize); 30 | bool WriteMihoyoDriverMemoryIntoFile(); 31 | bool WriteGACDriverMemoryIntoFile(); 32 | bool DeleteDriverFile(const char* chDriverDirectory); 33 | bool CreateAndStartDriverService(const char* chServiceName, const char* chDriverDirectory); 34 | bool StopAndDeleteDriverService(const char* chServiceName, const char* chDriverDirectory); 35 | bool ServiceIsRunning(const char* chServiceName); 36 | void StopAndDeleteAllDrivers(); 37 | } 38 | 39 | namespace Utilities 40 | { 41 | class Variables : public Singleton 42 | { 43 | public: 44 | ////https://www.vergiliusproject.com/kernels/x64/Windows%2010%20%7C%202016/2009%2020H2%20(October%202020%20Update)/_EPROCESS 45 | uintptr_t pSystemBaseOffset = 0x0; 46 | uintptr_t pImageFileNameOffset = 0x5A8; // EPROCESS-> 47 | uintptr_t pUniqueProcessIdOffset = 0x440; // EPROCESS-> 48 | uintptr_t pSectionBaseOffset = 0x520; // EPROCESS-> 49 | uintptr_t pActiveProcessLinkOffset = 0x448; // EPROCESS-> 50 | uintptr_t pPEBOffset = 0x550; // EPROCESS -> 51 | }; 52 | #define UtilVars Utilities::Variables::Get() 53 | void GetDesktopResolution(int& horizontal, int& vertical); 54 | PCHAR MD5(PCHAR chText); 55 | string StrReplace(std::string str, const std::string& from, const std::string& to); 56 | bool ReadFileToMemory(const std::string& strFilePath, std::vector* pOutBuffer); 57 | bool ConvertFileToByteArray(const char* chFileName, const char* chFileDestination); 58 | bool UpdateEPROCESSOffsets(); 59 | uintptr_t TranslateLinearAddress(uint64_t pDirectoryTableBaseAddress, uint64_t pVirtualAddress); 60 | uintptr_t SFGetEPROCESS(int dwProcessId); 61 | uintptr_t GetEPROCESS(int dwProcessId); 62 | uintptr_t GetKernelModuleAddress(const std::string& strModuleName); 63 | uintptr_t GetProcessBaseAddress(int dwProcessId); 64 | DWORD GetProcessIdByName(const wchar_t* chProcessName); 65 | DWORD GetProcessIdByContainingString(const wchar_t* wcProcessName); 66 | bool IsProcessBeingDebugged64(int dwProcessId); 67 | ULONG GetModuleBaseAddress32(int dwProcessId, const wchar_t* wcModuleName, DWORD* pdwSize, DWORD dwMaxCount = 1024); 68 | uintptr_t GetModuleBaseAddress64(int dwProcessId, const wchar_t* wcModuleName, DWORD* pdwSize); 69 | uintptr_t SearchSignature(DWORD dwProcessId, uintptr_t pStartAddress, SIZE_T szLength, BYTE* bPattern, const char* chMask); 70 | uintptr_t FindPattern(DWORD dwProcessId, uintptr_t pModuleAddress, SIZE_T szModuleSize, BYTE* bPattern, const char* chMask); 71 | uintptr_t ExtractOffsetByPattern(DWORD dwProcessId, uintptr_t pModuleAddress, SIZE_T szModuleSize, ULONG ulAdditionalOffset, ULONG ulExtra, const char* chPattern, const char* chMask, BOOLEAN bRelative); 72 | OSVERSIONINFOEXW GetOSVersionInfo(); 73 | }; -------------------------------------------------------------------------------- /mhyprotPOC/XorStr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #define BEGIN_NAMESPACE( x ) namespace x { 7 | #define END_NAMESPACE } 8 | 9 | BEGIN_NAMESPACE(XorCompileTime) 10 | 11 | constexpr auto time = __TIME__; 12 | constexpr auto seed = static_cast(time[7]) + static_cast(time[6]) * 10 + static_cast(time[4]) * 60 + static_cast(time[3]) * 600 + static_cast(time[1]) * 3600 + static_cast(time[0]) * 36000; 13 | 14 | // 1988, Stephen Park and Keith Miller 15 | // "Random Number Generators: Good Ones Are Hard To Find", considered as "minimal standard" 16 | // Park-Miller 31 bit pseudo-random number generator, implemented with G. Carta's optimisation: 17 | // with 32-bit math and without division 18 | 19 | template < int N > 20 | struct RandomGenerator 21 | { 22 | private: 23 | static constexpr unsigned a = 16807; // 7^5 24 | static constexpr unsigned m = 2147483647; // 2^31 - 1 25 | 26 | static constexpr unsigned s = RandomGenerator< N - 1 >::value; 27 | static constexpr unsigned lo = a * (s & 0xFFFF); // Multiply lower 16 bits by 16807 28 | static constexpr unsigned hi = a * (s >> 16); // Multiply higher 16 bits by 16807 29 | static constexpr unsigned lo2 = lo + ((hi & 0x7FFF) << 16); // Combine lower 15 bits of hi with lo's upper bits 30 | static constexpr unsigned hi2 = hi >> 15; // Discard lower 15 bits of hi 31 | static constexpr unsigned lo3 = lo2 + hi; 32 | 33 | public: 34 | static constexpr unsigned max = m; 35 | static constexpr unsigned value = lo3 > m ? lo3 - m : lo3; 36 | }; 37 | 38 | template <> 39 | struct RandomGenerator< 0 > 40 | { 41 | static constexpr unsigned value = seed; 42 | }; 43 | 44 | template < int N, int M > 45 | struct RandomInt 46 | { 47 | static constexpr auto value = RandomGenerator< N + 1 >::value % M; 48 | }; 49 | 50 | template < int N > 51 | struct RandomChar 52 | { 53 | static const char value = static_cast(1 + RandomInt< N, 0x7F - 1 >::value); 54 | }; 55 | 56 | template < size_t N, int K > 57 | struct XorString 58 | { 59 | private: 60 | const char _key; 61 | std::array< char, N + 1 > _encrypted; 62 | 63 | constexpr char enc(char c) const 64 | { 65 | return c ^ _key; 66 | } 67 | 68 | char dec(char c) const 69 | { 70 | return c ^ _key; 71 | } 72 | 73 | public: 74 | template < size_t... Is > 75 | constexpr __forceinline XorString(const char* str, std::index_sequence< Is... >) : _key(RandomChar< K >::value), _encrypted{ enc(str[Is])... } 76 | { 77 | } 78 | 79 | __forceinline decltype(auto) decrypt(void) 80 | { 81 | for (size_t i = 0; i < N; ++i) { 82 | _encrypted[i] = dec(_encrypted[i]); 83 | } 84 | _encrypted[N] = '\0'; 85 | return _encrypted.data(); 86 | } 87 | }; 88 | 89 | //-------------------------------------------------------------------------------- 90 | //-- Note: XorStr will __NOT__ work directly with functions like printf. 91 | // To work with them you need a wrapper function that takes a const char* 92 | // as parameter and passes it to printf and alike. 93 | // 94 | // The Microsoft Compiler/Linker is not working correctly with variadic 95 | // templates! 96 | // 97 | // Use the functions below or use std::cout (and similar)! 98 | //-------------------------------------------------------------------------------- 99 | 100 | static auto w_printf = [](const char* fmt, ...) { 101 | va_list args; 102 | va_start(args, fmt); 103 | vprintf_s(fmt, args); 104 | va_end(args); 105 | }; 106 | 107 | static auto w_printf_s = [](const char* fmt, ...) { 108 | va_list args; 109 | va_start(args, fmt); 110 | vprintf_s(fmt, args); 111 | va_end(args); 112 | }; 113 | 114 | static auto w_sprintf = [](char* buf, const char* fmt, ...) { 115 | va_list args; 116 | va_start(args, fmt); 117 | vsprintf(buf, fmt, args); 118 | va_end(args); 119 | }; 120 | 121 | static auto w_sprintf_s = [](char* buf, size_t buf_size, const char* fmt, ...) { 122 | va_list args; 123 | va_start(args, fmt); 124 | vsprintf_s(buf, buf_size, fmt, args); 125 | va_end(args); 126 | }; 127 | 128 | #ifdef NDEBUG 129 | #define XorStr( s ) ( XorCompileTime::XorString< sizeof( s ) - 1, __COUNTER__ >( s, std::make_index_sequence< sizeof( s ) - 1>() ).decrypt() ) 130 | #elif 131 | #define XorStr( s ) ( s ) 132 | #endif 133 | 134 | END_NAMESPACE 135 | -------------------------------------------------------------------------------- /mhyprotPOC/fonts/Century_Gothic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/fonts/Century_Gothic.ttf -------------------------------------------------------------------------------- /mhyprotPOC/fonts/kalra.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/fonts/kalra.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][Debug##Default] 2 | Pos=232,92 3 | Size=450,665 4 | Collapsed=0 5 | 6 | [Window][Luneware] 7 | Pos=170,305 8 | Size=808,516 9 | Collapsed=0 10 | 11 | [Window][##esp] 12 | Pos=10,10 13 | Size=1920,1080 14 | Collapsed=0 15 | 16 | [Window][iLuneware Panel] 17 | Pos=639,302 18 | Size=640,480 19 | Collapsed=0 20 | 21 | [Window][temp] 22 | Pos=271,365 23 | Size=640,471 24 | Collapsed=0 25 | 26 | [Window][##BOX] 27 | Pos=0,0 28 | Size=1920,1080 29 | Collapsed=0 30 | 31 | [Window][Jaguar Software Panel] 32 | Pos=671,301 33 | Size=640,480 34 | Collapsed=0 35 | 36 | [Window][##lolgay] 37 | Pos=0,0 38 | Size=1920,1080 39 | Collapsed=0 40 | 41 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec( dllexport ) 27 | //#define IMGUI_API __declspec( dllimport ) 28 | 29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 31 | 32 | //---- Disable all of Dear ImGui or don't implement standard windows. 33 | // It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. 34 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 35 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. 36 | //#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty. 37 | 38 | //---- Don't implement some functions to reduce linkage requirements. 39 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a) 41 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). 42 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 43 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 44 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 45 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) 46 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 47 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 48 | 49 | //---- Include imgui_user.h at the end of imgui.h as a convenience 50 | //#define IMGUI_INCLUDE_IMGUI_USER_H 51 | 52 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 53 | //#define IMGUI_USE_BGRA_PACKED_COLOR 54 | 55 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 56 | //#define IMGUI_USE_WCHAR32 57 | 58 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 59 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 60 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 61 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 62 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 63 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 64 | 65 | //---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 66 | // Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. 67 | // #define IMGUI_USE_STB_SPRINTF 68 | 69 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 70 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 71 | // On Windows you may use vcpkg with 'vcpkg install freetype' + 'vcpkg integrate install'. 72 | //#define IMGUI_ENABLE_FREETYPE 73 | 74 | //---- Use stb_truetype to build and rasterize the font atlas (default) 75 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 76 | //#define IMGUI_ENABLE_STB_TRUETYPE 77 | 78 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 79 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 80 | /* 81 | #define IM_VEC2_CLASS_EXTRA \ 82 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 83 | operator MyVec2() const { return MyVec2(x,y); } 84 | 85 | #define IM_VEC4_CLASS_EXTRA \ 86 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 87 | operator MyVec4() const { return MyVec4(x,y,z,w); } 88 | */ 89 | 90 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 91 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 92 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 93 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 94 | //#define ImDrawIdx unsigned int 95 | 96 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 97 | //struct ImDrawList; 98 | //struct ImDrawCmd; 99 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 100 | //#define ImDrawCallback MyImDrawCallback 101 | 102 | //---- Debug Tools: Macro to break in Debugger 103 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 104 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 105 | //#define IM_DEBUG_BREAK __debugbreak() 106 | 107 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), 108 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) 109 | // This adds a small runtime cost which is why it is not enabled by default. 110 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX 111 | 112 | //---- Debug Tools: Enable slower asserts 113 | //#define IMGUI_DEBUG_PARANOID 114 | 115 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 116 | /* 117 | namespace ImGui 118 | { 119 | void MyFunction(const char* name, const MyMatrix44& v); 120 | } 121 | */ 122 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/imgui_impl_dx10.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX10 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture backend. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | #pragma once 13 | #include "imgui.h" // IMGUI_IMPL_API 14 | 15 | struct ID3D10Device; 16 | 17 | IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device); 18 | IMGUI_IMPL_API void ImGui_ImplDX10_Shutdown(); 19 | IMGUI_IMPL_API void ImGui_ImplDX10_NewFrame(); 20 | IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data); 21 | 22 | // Use if you want to reset your rendering device without losing Dear ImGui state. 23 | IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects(); 24 | IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects(); 25 | -------------------------------------------------------------------------------- /mhyprotPOC/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: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | #pragma once 13 | #include "imgui.h" // IMGUI_IMPL_API 14 | 15 | struct ID3D11Device; 16 | struct ID3D11DeviceContext; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 19 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 25 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /mhyprotPOC/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: Support for large meshes (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 | // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. 10 | // This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file. 11 | 12 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 13 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 14 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 15 | 16 | #pragma once 17 | #include "imgui.h" // IMGUI_IMPL_API 18 | 19 | #ifdef _MSC_VER 20 | #pragma warning (push) 21 | #pragma warning (disable: 4471) // a forward declaration of an unscoped enumeration must have an underlying type 22 | #endif 23 | 24 | enum DXGI_FORMAT; 25 | struct ID3D12Device; 26 | struct ID3D12DescriptorHeap; 27 | struct ID3D12GraphicsCommandList; 28 | struct D3D12_CPU_DESCRIPTOR_HANDLE; 29 | struct D3D12_GPU_DESCRIPTOR_HANDLE; 30 | 31 | // cmd_list is the command list that the implementation will use to render imgui draw lists. 32 | // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate 33 | // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. 34 | // 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. 35 | IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, 36 | D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); 37 | IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); 38 | IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); 39 | IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); 40 | 41 | // Use if you want to reset your rendering device without losing Dear ImGui state. 42 | IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); 43 | IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); 44 | 45 | #ifdef _MSC_VER 46 | #pragma warning (pop) 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/imgui_impl_dx9.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 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 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | // CHANGELOG 13 | // (minor and older changes stripped away, please see git history for details) 14 | // 2021-05-19: DirectX9: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) 15 | // 2021-04-23: DirectX9: Explicitly setting up more graphics states to increase compatibility with unusual non-default states. 16 | // 2021-03-18: DirectX9: Calling IDirect3DStateBlock9::Capture() after CreateStateBlock() as a workaround for state restoring issues (see #3857). 17 | // 2021-03-03: DirectX9: Added support for IMGUI_USE_BGRA_PACKED_COLOR in user's imconfig file. 18 | // 2021-02-18: DirectX9: Change blending equation to preserve alpha in output buffer. 19 | // 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. 20 | // 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. 21 | // 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). 22 | // 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. 23 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. 24 | // 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. 25 | // 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. 26 | // 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. 27 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. 28 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. 29 | 30 | #include "imgui.h" 31 | #include "imgui_impl_dx9.h" 32 | 33 | // DirectX 34 | #include 35 | 36 | // DirectX data 37 | static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; 38 | static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; 39 | static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL; 40 | static LPDIRECT3DTEXTURE9 g_FontTexture = NULL; 41 | static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; 42 | 43 | struct CUSTOMVERTEX 44 | { 45 | float pos[3]; 46 | D3DCOLOR col; 47 | float uv[2]; 48 | }; 49 | #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) 50 | 51 | #ifdef IMGUI_USE_BGRA_PACKED_COLOR 52 | #define IMGUI_COL_TO_DX9_ARGB(_COL) (_COL) 53 | #else 54 | #define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16)) 55 | #endif 56 | 57 | static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) 58 | { 59 | // Setup viewport 60 | D3DVIEWPORT9 vp; 61 | vp.X = vp.Y = 0; 62 | vp.Width = (DWORD)draw_data->DisplaySize.x; 63 | vp.Height = (DWORD)draw_data->DisplaySize.y; 64 | vp.MinZ = 0.0f; 65 | vp.MaxZ = 1.0f; 66 | g_pd3dDevice->SetViewport(&vp); 67 | 68 | // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) 69 | g_pd3dDevice->SetPixelShader(NULL); 70 | g_pd3dDevice->SetVertexShader(NULL); 71 | g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); 72 | g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 73 | g_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); 74 | g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); 75 | g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); 76 | g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); 77 | g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); 78 | g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); 79 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); 80 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 81 | g_pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); 82 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE); 83 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA); 84 | g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); 85 | g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 86 | g_pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, FALSE); 87 | g_pd3dDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE); 88 | g_pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); 89 | g_pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE); 90 | g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 91 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); 92 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); 93 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); 94 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); 95 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); 96 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); 97 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); 98 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); 99 | 100 | // Setup orthographic projection matrix 101 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. 102 | // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() 103 | { 104 | float L = draw_data->DisplayPos.x + 0.5f; 105 | float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; 106 | float T = draw_data->DisplayPos.y + 0.5f; 107 | float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; 108 | D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; 109 | D3DMATRIX mat_projection = 110 | { { { 111 | 2.0f/(R-L), 0.0f, 0.0f, 0.0f, 112 | 0.0f, 2.0f/(T-B), 0.0f, 0.0f, 113 | 0.0f, 0.0f, 0.5f, 0.0f, 114 | (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f 115 | } } }; 116 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); 117 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); 118 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); 119 | } 120 | } 121 | 122 | // Render function. 123 | void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) 124 | { 125 | // Avoid rendering when minimized 126 | if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) 127 | return; 128 | 129 | // Create and grow buffers if needed 130 | if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) 131 | { 132 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 133 | g_VertexBufferSize = draw_data->TotalVtxCount + 5000; 134 | if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0) 135 | return; 136 | } 137 | if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) 138 | { 139 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 140 | g_IndexBufferSize = draw_data->TotalIdxCount + 10000; 141 | if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0) 142 | return; 143 | } 144 | 145 | // Backup the DX9 state 146 | IDirect3DStateBlock9* d3d9_state_block = NULL; 147 | if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) 148 | return; 149 | if (d3d9_state_block->Capture() < 0) 150 | { 151 | d3d9_state_block->Release(); 152 | return; 153 | } 154 | 155 | // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) 156 | D3DMATRIX last_world, last_view, last_projection; 157 | g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); 158 | g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); 159 | g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); 160 | 161 | // Allocate buffers 162 | CUSTOMVERTEX* vtx_dst; 163 | ImDrawIdx* idx_dst; 164 | if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) 165 | { 166 | d3d9_state_block->Release(); 167 | return; 168 | } 169 | if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) 170 | { 171 | g_pVB->Unlock(); 172 | d3d9_state_block->Release(); 173 | return; 174 | } 175 | 176 | // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. 177 | // FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and 178 | // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR 179 | // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } 180 | for (int n = 0; n < draw_data->CmdListsCount; n++) 181 | { 182 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 183 | const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; 184 | for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) 185 | { 186 | vtx_dst->pos[0] = vtx_src->pos.x; 187 | vtx_dst->pos[1] = vtx_src->pos.y; 188 | vtx_dst->pos[2] = 0.0f; 189 | vtx_dst->col = IMGUI_COL_TO_DX9_ARGB(vtx_src->col); 190 | vtx_dst->uv[0] = vtx_src->uv.x; 191 | vtx_dst->uv[1] = vtx_src->uv.y; 192 | vtx_dst++; 193 | vtx_src++; 194 | } 195 | memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); 196 | idx_dst += cmd_list->IdxBuffer.Size; 197 | } 198 | g_pVB->Unlock(); 199 | g_pIB->Unlock(); 200 | g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); 201 | g_pd3dDevice->SetIndices(g_pIB); 202 | g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); 203 | 204 | // Setup desired DX state 205 | ImGui_ImplDX9_SetupRenderState(draw_data); 206 | 207 | // Render command lists 208 | // (Because we merged all buffers into a single one, we maintain our own offset into them) 209 | int global_vtx_offset = 0; 210 | int global_idx_offset = 0; 211 | ImVec2 clip_off = draw_data->DisplayPos; 212 | for (int n = 0; n < draw_data->CmdListsCount; n++) 213 | { 214 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 215 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) 216 | { 217 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; 218 | if (pcmd->UserCallback != NULL) 219 | { 220 | // User callback, registered via ImDrawList::AddCallback() 221 | // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) 222 | if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) 223 | ImGui_ImplDX9_SetupRenderState(draw_data); 224 | else 225 | pcmd->UserCallback(cmd_list, pcmd); 226 | } 227 | else 228 | { 229 | const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) }; 230 | const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->GetTexID(); 231 | g_pd3dDevice->SetTexture(0, texture); 232 | g_pd3dDevice->SetScissorRect(&r); 233 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); 234 | } 235 | } 236 | global_idx_offset += cmd_list->IdxBuffer.Size; 237 | global_vtx_offset += cmd_list->VtxBuffer.Size; 238 | } 239 | 240 | // Restore the DX9 transform 241 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); 242 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); 243 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); 244 | 245 | // Restore the DX9 state 246 | d3d9_state_block->Apply(); 247 | d3d9_state_block->Release(); 248 | } 249 | 250 | bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) 251 | { 252 | // Setup backend capabilities flags 253 | ImGuiIO& io = ImGui::GetIO(); 254 | io.BackendRendererName = "imgui_impl_dx9"; 255 | io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. 256 | 257 | g_pd3dDevice = device; 258 | g_pd3dDevice->AddRef(); 259 | return true; 260 | } 261 | 262 | void ImGui_ImplDX9_Shutdown() 263 | { 264 | ImGui_ImplDX9_InvalidateDeviceObjects(); 265 | if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } 266 | } 267 | 268 | static bool ImGui_ImplDX9_CreateFontsTexture() 269 | { 270 | // Build texture atlas 271 | ImGuiIO& io = ImGui::GetIO(); 272 | unsigned char* pixels; 273 | int width, height, bytes_per_pixel; 274 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); 275 | 276 | // Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices) 277 | #ifndef IMGUI_USE_BGRA_PACKED_COLOR 278 | if (io.Fonts->TexPixelsUseColors) 279 | { 280 | ImU32* dst_start = (ImU32*)ImGui::MemAlloc(width * height * bytes_per_pixel); 281 | for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + width * height; dst < dst_end; src++, dst++) 282 | *dst = IMGUI_COL_TO_DX9_ARGB(*src); 283 | pixels = (unsigned char*)dst_start; 284 | } 285 | #endif 286 | 287 | // Upload texture to graphics system 288 | g_FontTexture = NULL; 289 | if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0) 290 | return false; 291 | D3DLOCKED_RECT tex_locked_rect; 292 | if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) 293 | return false; 294 | for (int y = 0; y < height; y++) 295 | memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel)); 296 | g_FontTexture->UnlockRect(0); 297 | 298 | // Store our identifier 299 | io.Fonts->SetTexID((ImTextureID)g_FontTexture); 300 | 301 | #ifndef IMGUI_USE_BGRA_PACKED_COLOR 302 | if (io.Fonts->TexPixelsUseColors) 303 | ImGui::MemFree(pixels); 304 | #endif 305 | 306 | return true; 307 | } 308 | 309 | bool ImGui_ImplDX9_CreateDeviceObjects() 310 | { 311 | if (!g_pd3dDevice) 312 | return false; 313 | if (!ImGui_ImplDX9_CreateFontsTexture()) 314 | return false; 315 | return true; 316 | } 317 | 318 | void ImGui_ImplDX9_InvalidateDeviceObjects() 319 | { 320 | if (!g_pd3dDevice) 321 | return; 322 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 323 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 324 | if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. 325 | } 326 | 327 | void ImGui_ImplDX9_NewFrame() 328 | { 329 | if (!g_FontTexture) 330 | ImGui_ImplDX9_CreateDeviceObjects(); 331 | } 332 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/imgui_impl_dx9.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 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 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 10 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 11 | 12 | #pragma once 13 | #include "imgui.h" // IMGUI_IMPL_API 14 | 15 | struct IDirect3DDevice9; 16 | 17 | IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); 18 | IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); 19 | IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); 20 | IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); 21 | 22 | // Use if you want to reset your rendering device without losing Dear ImGui state. 23 | IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); 24 | IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); 25 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 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 cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | 10 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 12 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 13 | 14 | #pragma once 15 | #include "imgui.h" // IMGUI_IMPL_API 16 | 17 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 18 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 20 | 21 | // Win32 message handler your application need to call. 22 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 23 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 24 | #if 0 25 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 26 | #endif 27 | 28 | // DPI-related helpers (optional) 29 | // - Use to enable DPI awareness without having to create an application manifest. 30 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 31 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 32 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 33 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 34 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 35 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 36 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 37 | 38 | // Transparency related helpers (optional) [experimental] 39 | // - Use to enable alpha compositing transparency with the desktop. 40 | // - Use together with e.g. clearing your framebuffer with zero-alpha. 41 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd 42 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.00. 3 | // Those changes would need to be pushed into nothings/stb: 4 | // - Added STBRP__CDECL 5 | // Grep for [DEAR IMGUI] to find the changes. 6 | 7 | // stb_rect_pack.h - v1.00 - public domain - rectangle packing 8 | // Sean Barrett 2014 9 | // 10 | // Useful for e.g. packing rectangular textures into an atlas. 11 | // Does not do rotation. 12 | // 13 | // Not necessarily the awesomest packing method, but better than 14 | // the totally naive one in stb_truetype (which is primarily what 15 | // this is meant to replace). 16 | // 17 | // Has only had a few tests run, may have issues. 18 | // 19 | // More docs to come. 20 | // 21 | // No memory allocations; uses qsort() and assert() from stdlib. 22 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 23 | // 24 | // This library currently uses the Skyline Bottom-Left algorithm. 25 | // 26 | // Please note: better rectangle packers are welcome! Please 27 | // implement them to the same API, but with a different init 28 | // function. 29 | // 30 | // Credits 31 | // 32 | // Library 33 | // Sean Barrett 34 | // Minor features 35 | // Martins Mozeiko 36 | // github:IntellectualKitty 37 | // 38 | // Bugfixes / warning fixes 39 | // Jeremy Jaussaud 40 | // Fabian Giesen 41 | // 42 | // Version history: 43 | // 44 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 45 | // 0.99 (2019-02-07) warning fixes 46 | // 0.11 (2017-03-03) return packing success/fail result 47 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 48 | // 0.09 (2016-08-27) fix compiler warnings 49 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 50 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 51 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 52 | // 0.05: added STBRP_ASSERT to allow replacing assert 53 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 54 | // 0.01: initial release 55 | // 56 | // LICENSE 57 | // 58 | // See end of file for license information. 59 | 60 | ////////////////////////////////////////////////////////////////////////////// 61 | // 62 | // INCLUDE SECTION 63 | // 64 | 65 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 66 | #define STB_INCLUDE_STB_RECT_PACK_H 67 | 68 | #define STB_RECT_PACK_VERSION 1 69 | 70 | #ifdef STBRP_STATIC 71 | #define STBRP_DEF static 72 | #else 73 | #define STBRP_DEF extern 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | 80 | typedef struct stbrp_context stbrp_context; 81 | typedef struct stbrp_node stbrp_node; 82 | typedef struct stbrp_rect stbrp_rect; 83 | 84 | #ifdef STBRP_LARGE_RECTS 85 | typedef int stbrp_coord; 86 | #else 87 | typedef unsigned short stbrp_coord; 88 | #endif 89 | 90 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 91 | // Assign packed locations to rectangles. The rectangles are of type 92 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 93 | // are 'num_rects' many of them. 94 | // 95 | // Rectangles which are successfully packed have the 'was_packed' flag 96 | // set to a non-zero value and 'x' and 'y' store the minimum location 97 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 98 | // if you imagine y increasing downwards). Rectangles which do not fit 99 | // have the 'was_packed' flag set to 0. 100 | // 101 | // You should not try to access the 'rects' array from another thread 102 | // while this function is running, as the function temporarily reorders 103 | // the array while it executes. 104 | // 105 | // To pack into another rectangle, you need to call stbrp_init_target 106 | // again. To continue packing into the same rectangle, you can call 107 | // this function again. Calling this multiple times with multiple rect 108 | // arrays will probably produce worse packing results than calling it 109 | // a single time with the full rectangle array, but the option is 110 | // available. 111 | // 112 | // The function returns 1 if all of the rectangles were successfully 113 | // packed and 0 otherwise. 114 | 115 | struct stbrp_rect 116 | { 117 | // reserved for your use: 118 | int id; 119 | 120 | // input: 121 | stbrp_coord w, h; 122 | 123 | // output: 124 | stbrp_coord x, y; 125 | int was_packed; // non-zero if valid packing 126 | 127 | }; // 16 bytes, nominally 128 | 129 | 130 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 131 | // Initialize a rectangle packer to: 132 | // pack a rectangle that is 'width' by 'height' in dimensions 133 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 134 | // 135 | // You must call this function every time you start packing into a new target. 136 | // 137 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 138 | // the following stbrp_pack_rects() call (or calls), but can be freed after 139 | // the call (or calls) finish. 140 | // 141 | // Note: to guarantee best results, either: 142 | // 1. make sure 'num_nodes' >= 'width' 143 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 144 | // 145 | // If you don't do either of the above things, widths will be quantized to multiples 146 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 147 | // 148 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 149 | // may run out of temporary storage and be unable to pack some rectangles. 150 | 151 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 152 | // Optionally call this function after init but before doing any packing to 153 | // change the handling of the out-of-temp-memory scenario, described above. 154 | // If you call init again, this will be reset to the default (false). 155 | 156 | 157 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 158 | // Optionally select which packing heuristic the library should use. Different 159 | // heuristics will produce better/worse results for different data sets. 160 | // If you call init again, this will be reset to the default. 161 | 162 | enum 163 | { 164 | STBRP_HEURISTIC_Skyline_default=0, 165 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 166 | STBRP_HEURISTIC_Skyline_BF_sortHeight 167 | }; 168 | 169 | 170 | ////////////////////////////////////////////////////////////////////////////// 171 | // 172 | // the details of the following structures don't matter to you, but they must 173 | // be visible so you can handle the memory allocations for them 174 | 175 | struct stbrp_node 176 | { 177 | stbrp_coord x,y; 178 | stbrp_node *next; 179 | }; 180 | 181 | struct stbrp_context 182 | { 183 | int width; 184 | int height; 185 | int align; 186 | int init_mode; 187 | int heuristic; 188 | int num_nodes; 189 | stbrp_node *active_head; 190 | stbrp_node *free_head; 191 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 192 | }; 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif 199 | 200 | ////////////////////////////////////////////////////////////////////////////// 201 | // 202 | // IMPLEMENTATION SECTION 203 | // 204 | 205 | #ifdef STB_RECT_PACK_IMPLEMENTATION 206 | #ifndef STBRP_SORT 207 | #include 208 | #define STBRP_SORT qsort 209 | #endif 210 | 211 | #ifndef STBRP_ASSERT 212 | #include 213 | #define STBRP_ASSERT assert 214 | #endif 215 | 216 | // [DEAR IMGUI] Added STBRP__CDECL 217 | #ifdef _MSC_VER 218 | #define STBRP__NOTUSED(v) (void)(v) 219 | #define STBRP__CDECL __cdecl 220 | #else 221 | #define STBRP__NOTUSED(v) (void)sizeof(v) 222 | #define STBRP__CDECL 223 | #endif 224 | 225 | enum 226 | { 227 | STBRP__INIT_skyline = 1 228 | }; 229 | 230 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 231 | { 232 | switch (context->init_mode) { 233 | case STBRP__INIT_skyline: 234 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 235 | context->heuristic = heuristic; 236 | break; 237 | default: 238 | STBRP_ASSERT(0); 239 | } 240 | } 241 | 242 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 243 | { 244 | if (allow_out_of_mem) 245 | // if it's ok to run out of memory, then don't bother aligning them; 246 | // this gives better packing, but may fail due to OOM (even though 247 | // the rectangles easily fit). @TODO a smarter approach would be to only 248 | // quantize once we've hit OOM, then we could get rid of this parameter. 249 | context->align = 1; 250 | else { 251 | // if it's not ok to run out of memory, then quantize the widths 252 | // so that num_nodes is always enough nodes. 253 | // 254 | // I.e. num_nodes * align >= width 255 | // align >= width / num_nodes 256 | // align = ceil(width/num_nodes) 257 | 258 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 259 | } 260 | } 261 | 262 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 263 | { 264 | int i; 265 | #ifndef STBRP_LARGE_RECTS 266 | STBRP_ASSERT(width <= 0xffff && height <= 0xffff); 267 | #endif 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | #ifdef STBRP_LARGE_RECTS 287 | context->extra[1].y = (1<<30); 288 | #else 289 | context->extra[1].y = 65535; 290 | #endif 291 | context->extra[1].next = NULL; 292 | } 293 | 294 | // find minimum y position if it starts at x1 295 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 296 | { 297 | stbrp_node *node = first; 298 | int x1 = x0 + width; 299 | int min_y, visited_width, waste_area; 300 | 301 | STBRP__NOTUSED(c); 302 | 303 | STBRP_ASSERT(first->x <= x0); 304 | 305 | #if 0 306 | // skip in case we're past the node 307 | while (node->next->x <= x0) 308 | ++node; 309 | #else 310 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 311 | #endif 312 | 313 | STBRP_ASSERT(node->x <= x0); 314 | 315 | min_y = 0; 316 | waste_area = 0; 317 | visited_width = 0; 318 | while (node->x < x1) { 319 | if (node->y > min_y) { 320 | // raise min_y higher. 321 | // we've accounted for all waste up to min_y, 322 | // but we'll now add more waste for everything we've visted 323 | waste_area += visited_width * (node->y - min_y); 324 | min_y = node->y; 325 | // the first time through, visited_width might be reduced 326 | if (node->x < x0) 327 | visited_width += node->next->x - x0; 328 | else 329 | visited_width += node->next->x - node->x; 330 | } else { 331 | // add waste area 332 | int under_width = node->next->x - node->x; 333 | if (under_width + visited_width > width) 334 | under_width = width - visited_width; 335 | waste_area += under_width * (min_y - node->y); 336 | visited_width += under_width; 337 | } 338 | node = node->next; 339 | } 340 | 341 | *pwaste = waste_area; 342 | return min_y; 343 | } 344 | 345 | typedef struct 346 | { 347 | int x,y; 348 | stbrp_node **prev_link; 349 | } stbrp__findresult; 350 | 351 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 352 | { 353 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 354 | stbrp__findresult fr; 355 | stbrp_node **prev, *node, *tail, **best = NULL; 356 | 357 | // align to multiple of c->align 358 | width = (width + c->align - 1); 359 | width -= width % c->align; 360 | STBRP_ASSERT(width % c->align == 0); 361 | 362 | // if it can't possibly fit, bail immediately 363 | if (width > c->width || height > c->height) { 364 | fr.prev_link = NULL; 365 | fr.x = fr.y = 0; 366 | return fr; 367 | } 368 | 369 | node = c->active_head; 370 | prev = &c->active_head; 371 | while (node->x + width <= c->width) { 372 | int y,waste; 373 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 374 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 375 | // bottom left 376 | if (y < best_y) { 377 | best_y = y; 378 | best = prev; 379 | } 380 | } else { 381 | // best-fit 382 | if (y + height <= c->height) { 383 | // can only use it if it first vertically 384 | if (y < best_y || (y == best_y && waste < best_waste)) { 385 | best_y = y; 386 | best_waste = waste; 387 | best = prev; 388 | } 389 | } 390 | } 391 | prev = &node->next; 392 | node = node->next; 393 | } 394 | 395 | best_x = (best == NULL) ? 0 : (*best)->x; 396 | 397 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 398 | // 399 | // e.g, if fitting 400 | // 401 | // ____________________ 402 | // |____________________| 403 | // 404 | // into 405 | // 406 | // | | 407 | // | ____________| 408 | // |____________| 409 | // 410 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 411 | // 412 | // This makes BF take about 2x the time 413 | 414 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 415 | tail = c->active_head; 416 | node = c->active_head; 417 | prev = &c->active_head; 418 | // find first node that's admissible 419 | while (tail->x < width) 420 | tail = tail->next; 421 | while (tail) { 422 | int xpos = tail->x - width; 423 | int y,waste; 424 | STBRP_ASSERT(xpos >= 0); 425 | // find the left position that matches this 426 | while (node->next->x <= xpos) { 427 | prev = &node->next; 428 | node = node->next; 429 | } 430 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 431 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 432 | if (y + height <= c->height) { 433 | if (y <= best_y) { 434 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 435 | best_x = xpos; 436 | STBRP_ASSERT(y <= best_y); 437 | best_y = y; 438 | best_waste = waste; 439 | best = prev; 440 | } 441 | } 442 | } 443 | tail = tail->next; 444 | } 445 | } 446 | 447 | fr.prev_link = best; 448 | fr.x = best_x; 449 | fr.y = best_y; 450 | return fr; 451 | } 452 | 453 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 454 | { 455 | // find best position according to heuristic 456 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 457 | stbrp_node *node, *cur; 458 | 459 | // bail if: 460 | // 1. it failed 461 | // 2. the best node doesn't fit (we don't always check this) 462 | // 3. we're out of memory 463 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 464 | res.prev_link = NULL; 465 | return res; 466 | } 467 | 468 | // on success, create new node 469 | node = context->free_head; 470 | node->x = (stbrp_coord) res.x; 471 | node->y = (stbrp_coord) (res.y + height); 472 | 473 | context->free_head = node->next; 474 | 475 | // insert the new node into the right starting point, and 476 | // let 'cur' point to the remaining nodes needing to be 477 | // stiched back in 478 | 479 | cur = *res.prev_link; 480 | if (cur->x < res.x) { 481 | // preserve the existing one, so start testing with the next one 482 | stbrp_node *next = cur->next; 483 | cur->next = node; 484 | cur = next; 485 | } else { 486 | *res.prev_link = node; 487 | } 488 | 489 | // from here, traverse cur and free the nodes, until we get to one 490 | // that shouldn't be freed 491 | while (cur->next && cur->next->x <= res.x + width) { 492 | stbrp_node *next = cur->next; 493 | // move the current node to the free list 494 | cur->next = context->free_head; 495 | context->free_head = cur; 496 | cur = next; 497 | } 498 | 499 | // stitch the list back in 500 | node->next = cur; 501 | 502 | if (cur->x < res.x + width) 503 | cur->x = (stbrp_coord) (res.x + width); 504 | 505 | #ifdef _DEBUG 506 | cur = context->active_head; 507 | while (cur->x < context->width) { 508 | STBRP_ASSERT(cur->x < cur->next->x); 509 | cur = cur->next; 510 | } 511 | STBRP_ASSERT(cur->next == NULL); 512 | 513 | { 514 | int count=0; 515 | cur = context->active_head; 516 | while (cur) { 517 | cur = cur->next; 518 | ++count; 519 | } 520 | cur = context->free_head; 521 | while (cur) { 522 | cur = cur->next; 523 | ++count; 524 | } 525 | STBRP_ASSERT(count == context->num_nodes+2); 526 | } 527 | #endif 528 | 529 | return res; 530 | } 531 | 532 | // [DEAR IMGUI] Added STBRP__CDECL 533 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 534 | { 535 | const stbrp_rect *p = (const stbrp_rect *) a; 536 | const stbrp_rect *q = (const stbrp_rect *) b; 537 | if (p->h > q->h) 538 | return -1; 539 | if (p->h < q->h) 540 | return 1; 541 | return (p->w > q->w) ? -1 : (p->w < q->w); 542 | } 543 | 544 | // [DEAR IMGUI] Added STBRP__CDECL 545 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 546 | { 547 | const stbrp_rect *p = (const stbrp_rect *) a; 548 | const stbrp_rect *q = (const stbrp_rect *) b; 549 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 550 | } 551 | 552 | #ifdef STBRP_LARGE_RECTS 553 | #define STBRP__MAXVAL 0xffffffff 554 | #else 555 | #define STBRP__MAXVAL 0xffff 556 | #endif 557 | 558 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 559 | { 560 | int i, all_rects_packed = 1; 561 | 562 | // we use the 'was_packed' field internally to allow sorting/unsorting 563 | for (i=0; i < num_rects; ++i) { 564 | rects[i].was_packed = i; 565 | } 566 | 567 | // sort according to heuristic 568 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 569 | 570 | for (i=0; i < num_rects; ++i) { 571 | if (rects[i].w == 0 || rects[i].h == 0) { 572 | rects[i].x = rects[i].y = 0; // empty rect needs no space 573 | } else { 574 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 575 | if (fr.prev_link) { 576 | rects[i].x = (stbrp_coord) fr.x; 577 | rects[i].y = (stbrp_coord) fr.y; 578 | } else { 579 | rects[i].x = rects[i].y = STBRP__MAXVAL; 580 | } 581 | } 582 | } 583 | 584 | // unsort 585 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 586 | 587 | // set was_packed flags and all_rects_packed status 588 | for (i=0; i < num_rects; ++i) { 589 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 590 | if (!rects[i].was_packed) 591 | all_rects_packed = 0; 592 | } 593 | 594 | // return the all_rects_packed status 595 | return all_rects_packed; 596 | } 597 | #endif 598 | 599 | /* 600 | ------------------------------------------------------------------------------ 601 | This software is available under 2 licenses -- choose whichever you prefer. 602 | ------------------------------------------------------------------------------ 603 | ALTERNATIVE A - MIT License 604 | Copyright (c) 2017 Sean Barrett 605 | Permission is hereby granted, free of charge, to any person obtaining a copy of 606 | this software and associated documentation files (the "Software"), to deal in 607 | the Software without restriction, including without limitation the rights to 608 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 609 | of the Software, and to permit persons to whom the Software is furnished to do 610 | so, subject to the following conditions: 611 | The above copyright notice and this permission notice shall be included in all 612 | copies or substantial portions of the Software. 613 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 614 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 615 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 616 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 617 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 618 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 619 | SOFTWARE. 620 | ------------------------------------------------------------------------------ 621 | ALTERNATIVE B - Public Domain (www.unlicense.org) 622 | This is free and unencumbered software released into the public domain. 623 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 624 | software, either in source code form or as a compiled binary, for any purpose, 625 | commercial or non-commercial, and by any means. 626 | In jurisdictions that recognize copyright laws, the author or authors of this 627 | software dedicate any and all copyright interest in the software to the public 628 | domain. We make this dedication for the benefit of the public at large and to 629 | the detriment of our heirs and successors. We intend this dedication to be an 630 | overt act of relinquishment in perpetuity of all present and future rights to 631 | this software under copyright law. 632 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 633 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 634 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 635 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 636 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 637 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 638 | ------------------------------------------------------------------------------ 639 | */ 640 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/cpp/imgui_stdlib.cpp: -------------------------------------------------------------------------------- 1 | // imgui_stdlib.cpp 2 | // Wrappers for C++ standard library (STL) types (std::string, etc.) 3 | // This is also an example of how you may wrap your own similar types. 4 | 5 | // Compatibility: 6 | // - std::string support is only guaranteed to work from C++11. 7 | // If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) 8 | 9 | // Changelog: 10 | // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string 11 | 12 | #include "../../imgui.h" 13 | #include "imgui_stdlib.h" 14 | 15 | struct InputTextCallback_UserData 16 | { 17 | std::string* Str; 18 | ImGuiInputTextCallback ChainCallback; 19 | void* ChainCallbackUserData; 20 | }; 21 | 22 | static int InputTextCallback(ImGuiInputTextCallbackData* data) 23 | { 24 | InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; 25 | if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) 26 | { 27 | // Resize string callback 28 | // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. 29 | std::string* str = user_data->Str; 30 | IM_ASSERT(data->Buf == str->c_str()); 31 | str->resize(data->BufTextLen); 32 | data->Buf = (char*)str->c_str(); 33 | } 34 | else if (user_data->ChainCallback) 35 | { 36 | // Forward to user callback, if any 37 | data->UserData = user_data->ChainCallbackUserData; 38 | return user_data->ChainCallback(data); 39 | } 40 | return 0; 41 | } 42 | 43 | bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) 44 | { 45 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 46 | flags |= ImGuiInputTextFlags_CallbackResize; 47 | 48 | InputTextCallback_UserData cb_user_data; 49 | cb_user_data.Str = str; 50 | cb_user_data.ChainCallback = callback; 51 | cb_user_data.ChainCallbackUserData = user_data; 52 | return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); 53 | } 54 | 55 | bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) 56 | { 57 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 58 | flags |= ImGuiInputTextFlags_CallbackResize; 59 | 60 | InputTextCallback_UserData cb_user_data; 61 | cb_user_data.Str = str; 62 | cb_user_data.ChainCallback = callback; 63 | cb_user_data.ChainCallbackUserData = user_data; 64 | return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data); 65 | } 66 | 67 | bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) 68 | { 69 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 70 | flags |= ImGuiInputTextFlags_CallbackResize; 71 | 72 | InputTextCallback_UserData cb_user_data; 73 | cb_user_data.Str = str; 74 | cb_user_data.ChainCallback = callback; 75 | cb_user_data.ChainCallbackUserData = user_data; 76 | return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); 77 | } 78 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/cpp/imgui_stdlib.h: -------------------------------------------------------------------------------- 1 | // imgui_stdlib.h 2 | // Wrappers for C++ standard library (STL) types (std::string, etc.) 3 | // This is also an example of how you may wrap your own similar types. 4 | 5 | // Compatibility: 6 | // - std::string support is only guaranteed to work from C++11. 7 | // If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) 8 | 9 | // Changelog: 10 | // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string 11 | 12 | #pragma once 13 | 14 | #include 15 | 16 | namespace ImGui 17 | { 18 | // ImGui::InputText() with std::string 19 | // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity 20 | IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 21 | IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 22 | IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 23 | } 24 | -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/Cousine-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/imgui/misc/fonts/Cousine-Regular.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/imgui/misc/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/Karla-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/imgui/misc/fonts/Karla-Regular.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/ProggyClean.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/imgui/misc/fonts/ProggyClean.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/ProggyTiny.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/imgui/misc/fonts/ProggyTiny.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cycript/pubApexCheat/9259795be4e4ad6a18e0f03653ff3cd1560cbf88/mhyprotPOC/imgui/misc/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /mhyprotPOC/imgui/misc/fonts/binary_to_compressed_c.cpp: -------------------------------------------------------------------------------- 1 | // ImGui - binary_to_compressed_c.cpp 2 | // Helper tool to turn a file into a C array, if you want to embed font data in your source code. 3 | 4 | // The data is first compressed with stb_compress() to reduce source code size, 5 | // then encoded in Base85 to fit in a string so we can fit roughly 4 bytes of compressed data into 5 bytes of source code (suggested by @mmalex) 6 | // (If we used 32-bits constants it would require take 11 bytes of source code to encode 4 bytes, and be endianness dependent) 7 | // Note that even with compression, the output array is likely to be bigger than the binary file.. 8 | // Load compressed TTF fonts with ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF() 9 | 10 | // Build with, e.g: 11 | // # cl.exe binary_to_compressed_c.cpp 12 | // # gcc binary_to_compressed_c.cpp 13 | // You can also find a precompiled Windows binary in the binary/demo package available from https://github.com/ocornut/imgui 14 | 15 | // Usage: 16 | // binary_to_compressed_c.exe [-base85] [-nocompress] 17 | // Usage example: 18 | // # binary_to_compressed_c.exe myfont.ttf MyFont > myfont.cpp 19 | // # binary_to_compressed_c.exe -base85 myfont.ttf MyFont > myfont.cpp 20 | 21 | #define _CRT_SECURE_NO_WARNINGS 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // stb_compress* from stb.h - declaration 28 | typedef unsigned int stb_uint; 29 | typedef unsigned char stb_uchar; 30 | stb_uint stb_compress(stb_uchar *out,stb_uchar *in,stb_uint len); 31 | 32 | static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression); 33 | 34 | int main(int argc, char** argv) 35 | { 36 | if (argc < 3) 37 | { 38 | printf("Syntax: %s [-base85] [-nocompress] \n", argv[0]); 39 | return 0; 40 | } 41 | 42 | int argn = 1; 43 | bool use_base85_encoding = false; 44 | bool use_compression = true; 45 | if (argv[argn][0] == '-') 46 | { 47 | if (strcmp(argv[argn], "-base85") == 0) { use_base85_encoding = true; argn++; } 48 | else if (strcmp(argv[argn], "-nocompress") == 0) { use_compression = false; argn++; } 49 | else 50 | { 51 | printf("Unknown argument: '%s'\n", argv[argn]); 52 | return 1; 53 | } 54 | } 55 | 56 | return binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression) ? 0 : 1; 57 | } 58 | 59 | char Encode85Byte(unsigned int x) 60 | { 61 | x = (x % 85) + 35; 62 | return (x>='\\') ? x+1 : x; 63 | } 64 | 65 | bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression) 66 | { 67 | // Read file 68 | FILE* f = fopen(filename, "rb"); 69 | if (!f) return false; 70 | int data_sz; 71 | if (fseek(f, 0, SEEK_END) || (data_sz = (int)ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) { fclose(f); return false; } 72 | char* data = new char[data_sz+4]; 73 | if (fread(data, 1, data_sz, f) != (size_t)data_sz) { fclose(f); delete[] data; return false; } 74 | memset((void*)(((char*)data) + data_sz), 0, 4); 75 | fclose(f); 76 | 77 | // Compress 78 | int maxlen = data_sz + 512 + (data_sz >> 2) + sizeof(int); // total guess 79 | char* compressed = use_compression ? new char[maxlen] : data; 80 | int compressed_sz = use_compression ? stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz) : data_sz; 81 | if (use_compression) 82 | memset(compressed + compressed_sz, 0, maxlen - compressed_sz); 83 | 84 | // Output as Base85 encoded 85 | FILE* out = stdout; 86 | fprintf(out, "// File: '%s' (%d bytes)\n", filename, (int)data_sz); 87 | fprintf(out, "// Exported using binary_to_compressed_c.cpp\n"); 88 | const char* compressed_str = use_compression ? "compressed_" : ""; 89 | if (use_base85_encoding) 90 | { 91 | fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz+3)/4)*5); 92 | char prev_c = 0; 93 | for (int src_i = 0; src_i < compressed_sz; src_i += 4) 94 | { 95 | // This is made a little more complicated by the fact that ??X sequences are interpreted as trigraphs by old C/C++ compilers. So we need to escape pairs of ??. 96 | unsigned int d = *(unsigned int*)(compressed + src_i); 97 | for (unsigned int n5 = 0; n5 < 5; n5++, d /= 85) 98 | { 99 | char c = Encode85Byte(d); 100 | fprintf(out, (c == '?' && prev_c == '?') ? "\\%c" : "%c", c); 101 | prev_c = c; 102 | } 103 | if ((src_i % 112) == 112-4) 104 | fprintf(out, "\"\n \""); 105 | } 106 | fprintf(out, "\";\n\n"); 107 | } 108 | else 109 | { 110 | fprintf(out, "static const unsigned int %s_%ssize = %d;\n", symbol, compressed_str, (int)compressed_sz); 111 | fprintf(out, "static const unsigned int %s_%sdata[%d/4] =\n{", symbol, compressed_str, (int)((compressed_sz+3)/4)*4); 112 | int column = 0; 113 | for (int i = 0; i < compressed_sz; i += 4) 114 | { 115 | unsigned int d = *(unsigned int*)(compressed + i); 116 | if ((column++ % 12) == 0) 117 | fprintf(out, "\n 0x%08x, ", d); 118 | else 119 | fprintf(out, "0x%08x, ", d); 120 | } 121 | fprintf(out, "\n};\n\n"); 122 | } 123 | 124 | // Cleanup 125 | delete[] data; 126 | if (use_compression) 127 | delete[] compressed; 128 | return true; 129 | } 130 | 131 | // stb_compress* from stb.h - definition 132 | 133 | //////////////////// compressor /////////////////////// 134 | 135 | static stb_uint stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen) 136 | { 137 | const unsigned long ADLER_MOD = 65521; 138 | unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; 139 | unsigned long blocklen, i; 140 | 141 | blocklen = buflen % 5552; 142 | while (buflen) { 143 | for (i=0; i + 7 < blocklen; i += 8) { 144 | s1 += buffer[0], s2 += s1; 145 | s1 += buffer[1], s2 += s1; 146 | s1 += buffer[2], s2 += s1; 147 | s1 += buffer[3], s2 += s1; 148 | s1 += buffer[4], s2 += s1; 149 | s1 += buffer[5], s2 += s1; 150 | s1 += buffer[6], s2 += s1; 151 | s1 += buffer[7], s2 += s1; 152 | 153 | buffer += 8; 154 | } 155 | 156 | for (; i < blocklen; ++i) 157 | s1 += *buffer++, s2 += s1; 158 | 159 | s1 %= ADLER_MOD, s2 %= ADLER_MOD; 160 | buflen -= blocklen; 161 | blocklen = 5552; 162 | } 163 | return (s2 << 16) + s1; 164 | } 165 | 166 | static unsigned int stb_matchlen(stb_uchar *m1, stb_uchar *m2, stb_uint maxlen) 167 | { 168 | stb_uint i; 169 | for (i=0; i < maxlen; ++i) 170 | if (m1[i] != m2[i]) return i; 171 | return i; 172 | } 173 | 174 | // simple implementation that just takes the source data in a big block 175 | 176 | static stb_uchar *stb__out; 177 | static FILE *stb__outfile; 178 | static stb_uint stb__outbytes; 179 | 180 | static void stb__write(unsigned char v) 181 | { 182 | fputc(v, stb__outfile); 183 | ++stb__outbytes; 184 | } 185 | 186 | //#define stb_out(v) (stb__out ? *stb__out++ = (stb_uchar) (v) : stb__write((stb_uchar) (v))) 187 | #define stb_out(v) do { if (stb__out) *stb__out++ = (stb_uchar) (v); else stb__write((stb_uchar) (v)); } while (0) 188 | 189 | static void stb_out2(stb_uint v) { stb_out(v >> 8); stb_out(v); } 190 | static void stb_out3(stb_uint v) { stb_out(v >> 16); stb_out(v >> 8); stb_out(v); } 191 | static void stb_out4(stb_uint v) { stb_out(v >> 24); stb_out(v >> 16); stb_out(v >> 8 ); stb_out(v); } 192 | 193 | static void outliterals(stb_uchar *in, int numlit) 194 | { 195 | while (numlit > 65536) { 196 | outliterals(in,65536); 197 | in += 65536; 198 | numlit -= 65536; 199 | } 200 | 201 | if (numlit == 0) ; 202 | else if (numlit <= 32) stb_out (0x000020 + numlit-1); 203 | else if (numlit <= 2048) stb_out2(0x000800 + numlit-1); 204 | else /* numlit <= 65536) */ stb_out3(0x070000 + numlit-1); 205 | 206 | if (stb__out) { 207 | memcpy(stb__out,in,numlit); 208 | stb__out += numlit; 209 | } else 210 | fwrite(in, 1, numlit, stb__outfile); 211 | } 212 | 213 | static int stb__window = 0x40000; // 256K 214 | 215 | static int stb_not_crap(int best, int dist) 216 | { 217 | return ((best > 2 && dist <= 0x00100) 218 | || (best > 5 && dist <= 0x04000) 219 | || (best > 7 && dist <= 0x80000)); 220 | } 221 | 222 | static stb_uint stb__hashsize = 32768; 223 | 224 | // note that you can play with the hashing functions all you 225 | // want without needing to change the decompressor 226 | #define stb__hc(q,h,c) (((h) << 7) + ((h) >> 25) + q[c]) 227 | #define stb__hc2(q,h,c,d) (((h) << 14) + ((h) >> 18) + (q[c] << 7) + q[d]) 228 | #define stb__hc3(q,c,d,e) ((q[c] << 14) + (q[d] << 7) + q[e]) 229 | 230 | static unsigned int stb__running_adler; 231 | 232 | static int stb_compress_chunk(stb_uchar *history, 233 | stb_uchar *start, 234 | stb_uchar *end, 235 | int length, 236 | int *pending_literals, 237 | stb_uchar **chash, 238 | stb_uint mask) 239 | { 240 | (void)history; 241 | int window = stb__window; 242 | stb_uint match_max; 243 | stb_uchar *lit_start = start - *pending_literals; 244 | stb_uchar *q = start; 245 | 246 | #define STB__SCRAMBLE(h) (((h) + ((h) >> 16)) & mask) 247 | 248 | // stop short of the end so we don't scan off the end doing 249 | // the hashing; this means we won't compress the last few bytes 250 | // unless they were part of something longer 251 | while (q < start+length && q+12 < end) { 252 | int m; 253 | stb_uint h1,h2,h3,h4, h; 254 | stb_uchar *t; 255 | int best = 2, dist=0; 256 | 257 | if (q+65536 > end) 258 | match_max = end-q; 259 | else 260 | match_max = 65536; 261 | 262 | #define stb__nc(b,d) ((d) <= window && ((b) > 9 || stb_not_crap(b,d))) 263 | 264 | #define STB__TRY(t,p) /* avoid retrying a match we already tried */ \ 265 | if (p ? dist != q-t : 1) \ 266 | if ((m = stb_matchlen(t, q, match_max)) > best) \ 267 | if (stb__nc(m,q-(t))) \ 268 | best = m, dist = q - (t) 269 | 270 | // rather than search for all matches, only try 4 candidate locations, 271 | // chosen based on 4 different hash functions of different lengths. 272 | // this strategy is inspired by LZO; hashing is unrolled here using the 273 | // 'hc' macro 274 | h = stb__hc3(q,0, 1, 2); h1 = STB__SCRAMBLE(h); 275 | t = chash[h1]; if (t) STB__TRY(t,0); 276 | h = stb__hc2(q,h, 3, 4); h2 = STB__SCRAMBLE(h); 277 | h = stb__hc2(q,h, 5, 6); t = chash[h2]; if (t) STB__TRY(t,1); 278 | h = stb__hc2(q,h, 7, 8); h3 = STB__SCRAMBLE(h); 279 | h = stb__hc2(q,h, 9,10); t = chash[h3]; if (t) STB__TRY(t,1); 280 | h = stb__hc2(q,h,11,12); h4 = STB__SCRAMBLE(h); 281 | t = chash[h4]; if (t) STB__TRY(t,1); 282 | 283 | // because we use a shared hash table, can only update it 284 | // _after_ we've probed all of them 285 | chash[h1] = chash[h2] = chash[h3] = chash[h4] = q; 286 | 287 | if (best > 2) 288 | assert(dist > 0); 289 | 290 | // see if our best match qualifies 291 | if (best < 3) { // fast path literals 292 | ++q; 293 | } else if (best > 2 && best <= 0x80 && dist <= 0x100) { 294 | outliterals(lit_start, q-lit_start); lit_start = (q += best); 295 | stb_out(0x80 + best-1); 296 | stb_out(dist-1); 297 | } else if (best > 5 && best <= 0x100 && dist <= 0x4000) { 298 | outliterals(lit_start, q-lit_start); lit_start = (q += best); 299 | stb_out2(0x4000 + dist-1); 300 | stb_out(best-1); 301 | } else if (best > 7 && best <= 0x100 && dist <= 0x80000) { 302 | outliterals(lit_start, q-lit_start); lit_start = (q += best); 303 | stb_out3(0x180000 + dist-1); 304 | stb_out(best-1); 305 | } else if (best > 8 && best <= 0x10000 && dist <= 0x80000) { 306 | outliterals(lit_start, q-lit_start); lit_start = (q += best); 307 | stb_out3(0x100000 + dist-1); 308 | stb_out2(best-1); 309 | } else if (best > 9 && dist <= 0x1000000) { 310 | if (best > 65536) best = 65536; 311 | outliterals(lit_start, q-lit_start); lit_start = (q += best); 312 | if (best <= 0x100) { 313 | stb_out(0x06); 314 | stb_out3(dist-1); 315 | stb_out(best-1); 316 | } else { 317 | stb_out(0x04); 318 | stb_out3(dist-1); 319 | stb_out2(best-1); 320 | } 321 | } else { // fallback literals if no match was a balanced tradeoff 322 | ++q; 323 | } 324 | } 325 | 326 | // if we didn't get all the way, add the rest to literals 327 | if (q-start < length) 328 | q = start+length; 329 | 330 | // the literals are everything from lit_start to q 331 | *pending_literals = (q - lit_start); 332 | 333 | stb__running_adler = stb_adler32(stb__running_adler, start, q - start); 334 | return q - start; 335 | } 336 | 337 | static int stb_compress_inner(stb_uchar *input, stb_uint length) 338 | { 339 | int literals = 0; 340 | stb_uint len,i; 341 | 342 | stb_uchar **chash; 343 | chash = (stb_uchar**) malloc(stb__hashsize * sizeof(stb_uchar*)); 344 | if (chash == NULL) return 0; // failure 345 | for (i=0; i < stb__hashsize; ++i) 346 | chash[i] = NULL; 347 | 348 | // stream signature 349 | stb_out(0x57); stb_out(0xbc); 350 | stb_out2(0); 351 | 352 | stb_out4(0); // 64-bit length requires 32-bit leading 0 353 | stb_out4(length); 354 | stb_out4(stb__window); 355 | 356 | stb__running_adler = 1; 357 | 358 | len = stb_compress_chunk(input, input, input+length, length, &literals, chash, stb__hashsize-1); 359 | assert(len == length); 360 | 361 | outliterals(input+length - literals, literals); 362 | 363 | free(chash); 364 | 365 | stb_out2(0x05fa); // end opcode 366 | 367 | stb_out4(stb__running_adler); 368 | 369 | return 1; // success 370 | } 371 | 372 | stb_uint stb_compress(stb_uchar *out, stb_uchar *input, stb_uint length) 373 | { 374 | stb__out = out; 375 | stb__outfile = NULL; 376 | 377 | stb_compress_inner(input, length); 378 | 379 | return stb__out - out; 380 | } 381 | -------------------------------------------------------------------------------- /mhyprotPOC/mhyprotPOC.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HID.h" 3 | #include "ApexLegends.h" 4 | #include "Threads.h" 5 | #include "Utilities.h" 6 | #include 7 | #include 8 | #include 9 | #include "Overlay.h" 10 | #include 11 | #include "XorStr.h" 12 | #pragma comment(lib, "dwmapi.lib") 13 | 14 | 15 | 16 | BOOL WINAPI ConsoleHandlerRoutine(DWORD dwCtrlType) 17 | { 18 | if (dwCtrlType == CTRL_CLOSE_EVENT) 19 | { 20 | Driver::StopAndDeleteAllDrivers(); 21 | return true; 22 | } 23 | return false; 24 | } 25 | 26 | const MARGINS margins = { -1 ,-1, -1, -1 }; 27 | const wchar_t g_szClassName[] = L"Luneware"; 28 | WNDCLASS wc = { }; 29 | static bool AlreadyInGame = true; 30 | static HWND OverlayHWND; 31 | 32 | 33 | 34 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 35 | { 36 | WNDCLASSEX wc; 37 | HWND hwnd; 38 | MSG Msg; 39 | wc.cbSize = sizeof(WNDCLASSEX); 40 | wc.style = CS_HREDRAW | CS_VREDRAW; 41 | wc.lpfnWndProc = DefWindowProc; 42 | wc.cbClsExtra = 0; 43 | wc.cbWndExtra = 0; 44 | 45 | wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 46 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 47 | wc.hbrBackground = (HBRUSH)(RGB(0, 0, 0)); 48 | wc.lpszMenuName = NULL; 49 | wc.lpszClassName = g_szClassName; 50 | wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); 51 | 52 | RegisterClassEx(&wc); 53 | 54 | hwnd = CreateWindowEx( 55 | WS_EX_LAYERED | WS_EX_TRANSPARENT, 56 | g_szClassName, 57 | g_szClassName, 58 | WS_POPUP | WS_VISIBLE, 59 | 0, 0, 1920, 1080, 60 | NULL, NULL, hInstance, NULL); 61 | OverlayHWND = hwnd; 62 | SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 255, LWA_ALPHA); 63 | DwmExtendFrameIntoClientArea(hwnd, &margins); 64 | while (GetMessage(&Msg, NULL, 0, 0) > 0) 65 | { 66 | TranslateMessage(&Msg); 67 | DispatchMessage(&Msg); 68 | } 69 | return 0; 70 | } 71 | void WindowOverlay() 72 | { 73 | WinMain((HINSTANCE)GetModuleHandle(NULL), NULL, NULL, 0); 74 | } 75 | void Pause(const char* message) 76 | { 77 | std::cout << message; 78 | HANDLE hStdin; 79 | DWORD cNumRead; 80 | INPUT_RECORD irInBuf[1]; 81 | if (HANDLE(hStdin = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) 82 | return; 83 | while (true) 84 | { 85 | if (!ReadConsoleInput(hStdin, irInBuf, 1, &cNumRead)) 86 | return; 87 | for (DWORD i = 0; i < cNumRead; ++i) 88 | if (irInBuf[i].EventType == KEY_EVENT && irInBuf[i].Event.KeyEvent.bKeyDown) 89 | { 90 | std::cout << '\n'; 91 | return; 92 | } 93 | } 94 | } 95 | 96 | void InitializeApexLegends() 97 | { 98 | printf("------------------------------------------------------------\n"); 99 | printf(" Jaguar Software - Apex Legends \n"); 100 | printf("------------------------------------------------------------\n"); 101 | printf("[?] Initializing exploit\n"); 102 | static bool bActive = true; 103 | if (mhyprotrose::MhyDebugInitialize()) 104 | { 105 | printf(" [+] Exploit initialized\n\n"); 106 | 107 | printf("[?] Searching for target process \n"); 108 | while (true) 109 | { 110 | DWORD dwApexPid = Utilities::GetProcessIdByName(APEXVars.wcProcessName); 111 | if (dwApexPid) 112 | { 113 | APEXVars.dwProcessId = dwApexPid; 114 | APEXVars.pBaseAddress = Utilities::GetProcessBaseAddress(APEXVars.dwProcessId); 115 | if (APEXVars.pBaseAddress != 0) 116 | 117 | printf((" [+] Target process found\n")); 118 | printf((" - PID : %d\n"), dwApexPid); 119 | printf((" - Module dependencies : \n")); 120 | printf((" - Base Address : 0x%X\n"), APEXVars.pBaseAddress); 121 | 122 | break; 123 | } 124 | AlreadyInGame = false; 125 | Sleep(5000); 126 | } 127 | if (!AlreadyInGame) { 128 | printf(("[?] Starting in 10 Seconds\n")); 129 | Sleep(10000); 130 | } 131 | else 132 | printf(("[?] Starting threads\n")); 133 | StartThreads: 134 | CFG.bActive = true; 135 | if (Configuration::FileExists(CFG.chConfigFile)) 136 | { 137 | if (Configuration::ShouldAutoInitFromFile()) 138 | { 139 | printf(" [+] Reading Variables from Config\n"); 140 | Configuration::UpdateConfigFromFile(); 141 | } 142 | } 143 | else 144 | { 145 | printf("Creating New Config File\n"); 146 | Configuration::WriteToConfigFile(); 147 | } 148 | 149 | ThreadVars.thApexLegendsThread = thread(Threads::ApexLegendsAimThread); 150 | ThreadVars.ItemGlowthread = thread(Threads::Itemglow); 151 | ThreadVars.tempPlayerGlow = thread(Threads::Glow); 152 | thread overlay = thread(WindowOverlay); 153 | // overlay.detach(); 154 | // ThreadVars.tempPlayerGlow.detach(); 155 | // ThreadVars.ItemGlowthread.detach(); 156 | Sleep(300); 157 | printf(" [+] Threads started\n"); 158 | printf("---------------------------------------------------------\n"); 159 | printf(" [~] Feel free to report any bugs to the developer! \n"); 160 | Overlay ovWindow = Overlay(); 161 | ovWindow.Start(OverlayHWND); 162 | ThreadVars.thApexLegendsThread.join(); 163 | } 164 | else 165 | { 166 | Driver::StopAndDeleteAllDrivers(); 167 | printf(" [-] Unable to initialize exploit\n")); 168 | Sleep(5000); 169 | return; 170 | } 171 | printf("Not good\n"); 172 | if(CFG.bActive) 173 | { 174 | printf("Caught An Error!!! Restarting threads in 1 second"); 175 | Sleep(600); 176 | goto StartThreads; 177 | } 178 | mhyprotrose::MhyDebugUnload(); 179 | } 180 | 181 | int main(HINSTANCE hINST) 182 | { 183 | SetConsoleTitleW((LPCWSTR)L"Lunariel Framework - Jaguar Software"); 184 | SetConsoleCtrlHandler(ConsoleHandlerRoutine, true); 185 | Driver::StopAndDeleteAllDrivers(); 186 | if (Utilities::UpdateEPROCESSOffsets()) 187 | { 188 | 189 | 190 | if (ShouldOverwriteCFG()) 191 | { 192 | Configuration::WriteToConfigFile(); 193 | } 194 | 195 | system("cls"); 196 | InitializeApexLegends(); 197 | 198 | } 199 | else 200 | { 201 | OSVERSIONINFOEXW osVersionInfo = Utilities::GetOSVersionInfo(); 202 | string strOSVersionInfo = to_string(osVersionInfo.dwMajorVersion) + "." + to_string(osVersionInfo.dwMinorVersion) + " - " + to_string(osVersionInfo.dwBuildNumber); 203 | string strMessage = "Your windows [" + strOSVersionInfo + "] is unsupported, please contact administrator"; 204 | MessageBoxA(NULL, strMessage.c_str(), "[pblLuneware] OS Unsupported", MB_OK); 205 | } 206 | return 0; 207 | } -------------------------------------------------------------------------------- /mhyprotPOC/mhyprotPOC.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {3eeb4220-403a-4f4b-b70b-9feadc8a05ab} 25 | LunewareApex 26 | 10.0 27 | LunewareApex 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v142 53 | true 54 | Unicode 55 | false 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | D:\Project\mhyprotPOC\Dependencies\mhyprotrose;$(IncludePath) 78 | D:\Project\mhyprotPOC\Dependencies\mhyprotrose;$(LibraryPath) 79 | 80 | 81 | false 82 | D:\Project\mhyprotPOC\Dependencies\mhyprotrose\Include;$(IncludePath) 83 | D:\Project\mhyprotPOC\Dependencies\mhyprotrose\Library;$(LibraryPath) 84 | 85 | 86 | true 87 | 88 | 89 | false 90 | $(DXSDK_DIR)Include;D:\Project\LunewareApex\Dependencies\curl\include\curl;D:\Project\LunewareApex\Dependencies\mhyprotrose\Include;$(IncludePath) 91 | $(DXSDK_DIR)Lib\x64;D:\Project\LunewareApex\Dependencies\curl\lib;D:\Project\LunewareApex\Dependencies\mhyprotrose\Library;$(LibraryPath) 92 | ..\build 93 | 94 | 95 | 96 | Level3 97 | true 98 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 99 | true 100 | 101 | 102 | Console 103 | true 104 | 105 | 106 | 107 | 108 | Level3 109 | true 110 | true 111 | true 112 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 113 | true 114 | 115 | 116 | Console 117 | true 118 | true 119 | true 120 | 121 | 122 | 123 | 124 | Level3 125 | true 126 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 127 | true 128 | 129 | 130 | Console 131 | true 132 | 133 | 134 | 135 | 136 | Level3 137 | true 138 | true 139 | true 140 | CURL_STATICLIB;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 141 | true 142 | Disabled 143 | false 144 | false 145 | stdcpp17 146 | Neither 147 | 148 | 149 | Console 150 | true 151 | true 152 | true 153 | mhyprotrose.lib;libcurl_a.lib;Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;%(AdditionalDependencies) 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /mhyprotPOC/mhyprotPOC.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {fb4ca732-2cad-4449-bb13-0c83943bd498} 18 | 19 | 20 | {afb49630-f725-4249-9c6f-e7eae6207fd0} 21 | 22 | 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Header Files\imgui 41 | 42 | 43 | Header Files\imgui 44 | 45 | 46 | Header Files\imgui 47 | 48 | 49 | Header Files\imgui 50 | 51 | 52 | Header Files\imgui 53 | 54 | 55 | Header Files\imgui 56 | 57 | 58 | Header Files\imgui 59 | 60 | 61 | Header Files\imgui 62 | 63 | 64 | Header Files\imgui 65 | 66 | 67 | Source Files 68 | 69 | 70 | Header Files\imgui 71 | 72 | 73 | Source Files 74 | 75 | 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files\imgui 121 | 122 | 123 | Header Files\imgui 124 | 125 | 126 | Header Files\imgui 127 | 128 | 129 | Header Files\imgui 130 | 131 | 132 | Header Files\imgui 133 | 134 | 135 | Header Files\imgui 136 | 137 | 138 | Header Files\imgui 139 | 140 | 141 | Header Files\imgui 142 | 143 | 144 | Header Files\imgui 145 | 146 | 147 | Header Files\imgui 148 | 149 | 150 | Header Files 151 | 152 | 153 | Header Files 154 | 155 | 156 | 157 | 158 | Resource Files 159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /mhyprotPOC/mhyprotPOC.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /mhyprotPOC/resource1.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by LunewareApex.rc 4 | // 5 | #define IDR_FONT1 104 6 | #define IDR_FONT2 105 7 | #define IDR_FONT3 106 8 | 9 | // Next default values for new objects 10 | // 11 | #ifdef APSTUDIO_INVOKED 12 | #ifndef APSTUDIO_READONLY_SYMBOLS 13 | #define _APS_NEXT_RESOURCE_VALUE 107 14 | #define _APS_NEXT_COMMAND_VALUE 40001 15 | #define _APS_NEXT_CONTROL_VALUE 1001 16 | #define _APS_NEXT_SYMED_VALUE 101 17 | #endif 18 | #endif 19 | --------------------------------------------------------------------------------