This commit is contained in:
Oscar
2025-07-25 22:49:56 +03:00
parent 03af6d458c
commit 860be9ac4c
470 changed files with 308020 additions and 436 deletions

View File

@@ -0,0 +1,138 @@
#include "Aimbot.h"
inline QAngle_t CalculateAngleScalar(const Vector_t& src, const Vector_t& dst)
{
QAngle_t Angles;
Vector_t Delta = { dst.x - src.x, dst.y - src.y, dst.z - src.z };
float hyp = std::sqrt(Delta.x * Delta.x + Delta.y * Delta.y);
Angles.x = std::atan2(-Delta.z, hyp) * (180.0f / M_PI);
Angles.y = std::atan2(Delta.y, Delta.x) * (180.0f / M_PI);
Angles.z = 0.0f;
return Angles;
}
VOID SilentAim(CUserCmd* pCmd)
{
if (!MenuConfig::EnableSilentAim || SDK::LocalPawn == nullptr)
return;
float ClosestDistance = FLT_MAX;
PlayerEntity* ClosestEntity = nullptr;
for (auto& Entity : *CurrentPlayerList)
{
if (Entity.Pawn.BoneData.BonePositions.empty())
continue;
bool CanAim = Entity.Pawn.isVisible;
if (!CanAim)
{
for (const auto& BonePosition : Entity.Pawn.BoneData.BonePositions)
{
if (BonePosition.RayTraceVisible)
{
CanAim = true;
break;
}
}
}
if (!CanAim)
continue;
float DistanceToLocal = SDK::LocalPawn->GetOrigin().DistTo(Entity.Pawn.m_vOldOrigin);
if (DistanceToLocal < ClosestDistance)
{
ClosestDistance = DistanceToLocal;
ClosestEntity = &Entity;
}
}
if (ClosestEntity != nullptr)
{
QAngle_t TargetAngles = CalculateAngleScalar(SDK::LocalPawn->GetOrigin() + SDK::LocalPawn->GetViewOffset(), ClosestEntity->Pawn.BoneData.BonePositions[BONEINDEX::Head].Location);
TargetAngles.Normalize();
TargetAngles.Clamp();
QAngle_t PunchAngle = SDK::LocalPawn->GetPunchAngle();
TargetAngles.x -= PunchAngle.x * 2.0f;
TargetAngles.y -= PunchAngle.y * 2.0f;
pCmd->SetSubTickAngle(TargetAngles);
}
}
VOID Aimbot(CCSGOInput* Input)
{
if (!MenuConfig::EnableAimbot || SDK::LocalPawn == nullptr)
return;
Vector2D_t MousePos = { ImGui::GetMousePos().x, ImGui::GetMousePos().y };
float MinDistanceToMouse = FLT_MAX;
Vector_t ClosestBoneWorldPos;
auto AimAtBone = [&](const std::vector<BonePosition>& BonePositions, int i)
{
if (BonePositions.empty() || i >= BonePositions.size())
return;
Vector_t BoneWorldPos = BonePositions[i].Location;
Vector2D_t BoneScreenPos;
if (View.WorldToScreen(BoneWorldPos, BoneScreenPos))
{
float Distance = MousePos.DistanceTo(BoneScreenPos);
if (Distance < MinDistanceToMouse && BonePositions[i].RayTraceVisible)
{
MinDistanceToMouse = Distance;
ClosestBoneWorldPos = BoneWorldPos;
}
}
};
if (MenuConfig::TargetClosestVisibleBoneToFov)
for (auto& Entity : *CurrentPlayerList)
for (int i = 0; i < Entity.Pawn.BoneData.BonePositions.size(); i++)
AimAtBone(Entity.Pawn.BoneData.BonePositions, i);
else
for (auto& Entity : *CurrentPlayerList)
AimAtBone(Entity.Pawn.BoneData.BonePositions, MenuConfig::SelectedBoneIndex);
if (MinDistanceToMouse <= MenuConfig::FOV && GetAsyncKeyState(HotKeyCodes[MenuConfig::SelectedHotkey]) & 0x8000)
{
Vector_t PlayerViewPosition = SDK::LocalPawn->GetOrigin() + SDK::LocalPawn->GetViewOffset();
QAngle_t TargetAngles = CalculateAngleScalar(PlayerViewPosition, ClosestBoneWorldPos);
if (SDK::LocalPawn->GetShotsFired() > 0)
{
QAngle_t PunchAngle = SDK::LocalPawn->GetPunchAngle();
TargetAngles.x -= PunchAngle.x * 2.0f;
TargetAngles.y -= PunchAngle.y * 2.0f;
}
TargetAngles.Normalize();
TargetAngles.Clamp();
QAngle_t CurrentAngles = Input->GetViewAngles();
float SmoothFactor = 1.0f / MenuConfig::AimSmoothness;
QAngle_t DeltaAngles(
(TargetAngles.x - CurrentAngles.x) * SmoothFactor,
(TargetAngles.y - CurrentAngles.y) * SmoothFactor);
QAngle_t SmoothAngles = CurrentAngles + DeltaAngles;
SmoothAngles.Normalize();
SmoothAngles.Clamp();
Input->SetViewAngle(SmoothAngles);
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "Entity.h"
#include "Bones.h"
#include "UserCmd.h"
#include "Hooks.h"
#include "CheatMenu.h"
#include "Utils/Defines.h"
VOID SilentAim(CUserCmd* pCmd);
VOID Aimbot(CCSGOInput* Input);

View File

@@ -0,0 +1,65 @@
#pragma once
#include "Windows.h"
#include "unordered_map"
#include "Utils/cVector.h"
enum BONEINDEX : DWORD
{
Pelvis = 0,
Spine_1 = 2,
Spine_2 = 3,
Spine_3 = 4,
Neck_0 = 5,
Head = 6,
Arm_Upper_L = 8,
Arm_Lower_L = 9,
Hand_L = 10,
Arm_Upper_R = 13,
Arm_Lower_R = 14,
Hand_R = 15,
Leg_Upper_L = 22,
Leg_Lower_L = 23,
Ankle_L = 24,
Leg_Upper_R = 25,
Leg_Lower_R = 26,
Ankle_R = 27,
};
struct BonePosition
{
Vector_t Location;
Vector2D_t ScreenPosition;
bool WorldVisible;
bool RayTraceVisible;
};
struct CBone
{
std::vector<BonePosition> BonePositions;
};
struct CBoneData
{
Vector_t Location;
float Scale;
char Padding[0x16];
};
namespace BoneJointList
{
inline std::list<DWORD> Trunk = { Pelvis, Spine_1, Spine_2, Spine_3, Neck_0, Head };
inline std::list<DWORD> LeftArm = { Spine_3, Arm_Upper_L, Arm_Lower_L, Hand_L };
inline std::list<DWORD> RightArm = { Spine_3, Arm_Upper_R, Arm_Lower_R, Hand_R };
inline std::list<DWORD> LeftLeg = { Pelvis, Leg_Upper_L, Leg_Lower_L, Ankle_L };
inline std::list<DWORD> RightLeg = { Pelvis, Leg_Upper_R, Leg_Lower_R, Ankle_R };
inline std::vector<std::list<DWORD>> List = { Trunk, LeftArm, RightArm, LeftLeg, RightLeg};
}

View File

@@ -0,0 +1,81 @@
#pragma once
#include "UserCMD.h"
#define MULTIPLAYER_BACKUP 150
class CTinyMoveStepData
{
public:
float flWhen; //0x0000
MEM_PAD(0x4); //0x0004
std::uint64_t nButton; //0x0008
bool bPressed; //0x0010
MEM_PAD(0x7); //0x0011
}; //Size: 0x0018
class CMoveStepButtons
{
public:
std::uint64_t nKeyboardPressed; //0x0000
std::uint64_t nMouseWheelheelPressed; //0x0008
std::uint64_t nUnPressed; //0x0010
std::uint64_t nKeyboardCopy; //0x0018
}; //Size: 0x0020
// @credits: www.unknowncheats.me/forum/members/2943409.html
class CExtendedMoveData : public CMoveStepButtons
{
public:
float flForwardMove; //0x0020
float flSideMove; //0x0024
float flUpMove; //0x0028
std::int32_t nMouseDeltaX; //0x002C
std::int32_t nMouseDeltaY; //0x0030
std::int32_t nAdditionalStepMovesCount; //0x0034
CTinyMoveStepData tinyMoveStepData[12]; //0x0038
Vector_t vecViewAngle; //0x0158
std::int32_t nTargetHandle; //0x0164
}; //Size:0x0168
class CCSGOInput
{
public:
MEM_PAD(0x250);
CUserCmd arrCommands[MULTIPLAYER_BACKUP];
MEM_PAD(0x99);
bool bInThirdPerson;
MEM_PAD(0x6);
QAngle_t angThirdPersonAngles;
MEM_PAD(0xE);
std::int32_t nSequenceNumber;
double dbSomeTimer;
CExtendedMoveData currentMoveData;
std::int32_t nWeaponSwitchTick;
MEM_PAD(0x1C4);
CExtendedMoveData* pExtendedMoveData;
MEM_PAD(0x48);
int32_t nAttackStartHistoryIndex1;
int32_t nAttackStartHistoryIndex2;
int32_t nAttackStartHistoryIndex3;
CUserCmd* GetUserCmd()
{
return &arrCommands[nSequenceNumber % MULTIPLAYER_BACKUP];
}
void SetViewAngle(QAngle_t& angView)
{
using fnSetViewAngle = std::int64_t(__fastcall*)(void*, std::int32_t, QAngle_t&);
static auto oSetViewAngle = reinterpret_cast<fnSetViewAngle>(M::FindPattern(CLIENT_DLL, "85 D2 75 3F 48"));
oSetViewAngle(this, 0, std::ref(angView));
}
QAngle_t GetViewAngles()
{
using fnGetViewAngles = std::int64_t(__fastcall*)(CCSGOInput*, std::int32_t);
static auto oGetViewAngles = reinterpret_cast<fnGetViewAngles>(M::FindPattern(CLIENT_DLL, "4C 8B C1 85 D2 74 08 48 8D 05 ? ? ? ? C3"));
return *reinterpret_cast<QAngle_t*>(oGetViewAngles(this, 0));
}
};

View File

@@ -0,0 +1,84 @@
#pragma once
#include <iostream>
#include "Utils/Memory.h"
#include "utlbuffer.h"
#include "UserCMD.h"
#include "iemalloc.h"
namespace CRC
{
struct CInButtonStateNoVTable
{
public:
std::uint64_t nValue;
std::uint64_t nValueChanged;
std::uint64_t nValueScroll;
};
struct SavedData_t
{
CInButtonStateNoVTable nButtons;
QAngle_t angView;
};
inline SavedData_t savedData;
inline void Save(CBaseUserCmdPB* pBaseCmd)
{
if (pBaseCmd->pViewAngles != nullptr)
savedData.angView = pBaseCmd->pViewAngles->angValue;
savedData.nButtons.nValue = pBaseCmd->pInButtonState->nValue;
savedData.nButtons.nValueChanged = pBaseCmd->pInButtonState->nValueChanged;
savedData.nButtons.nValueScroll = pBaseCmd->pInButtonState->nValueScroll;
}
inline void Apply(CUserCmd* pCmd)
{
CBaseUserCmdPB* pBaseCmd = pCmd->csgoUserCmd.pBaseCmd;
if (pBaseCmd == nullptr)
return;
pCmd->nButtons.nValue = savedData.nButtons.nValue;
pCmd->nButtons.nValueChanged = savedData.nButtons.nValueChanged;
pCmd->nButtons.nValueScroll = savedData.nButtons.nValueScroll;
if (pBaseCmd->pViewAngles != nullptr)
pBaseCmd->pViewAngles->angValue = savedData.angView;
}
inline bool CalculateCRC(CBaseUserCmdPB* pBaseCmd)
{
int nCalcualtedCRCSize = pBaseCmd->CalculateCmdCRCSize();
CUtlBuffer protobufBuffer(0, 0, 0);
protobufBuffer.EnsureCapacity(nCalcualtedCRCSize + 1);
using fnSerializePartialToArray = bool(__fastcall*)(CBaseUserCmdPB*, CUtlBuffer, int);
static const fnSerializePartialToArray oSerializePartialToArray = reinterpret_cast<fnSerializePartialToArray>(M::FindPattern(CLIENT_DLL, "48 89 5C 24 18 55 56 57 48 81 EC 90"));
if (oSerializePartialToArray(pBaseCmd, protobufBuffer, nCalcualtedCRCSize))
{
std::uintptr_t* pMessage = reinterpret_cast<uintptr_t*>(I::MemAlloc->Alloc(0x18));
pBaseCmd->nCachedBits |= 1;
auto nHasBits = static_cast<uint32_t>(pBaseCmd->nHasBits & 0xFFFFFFFFFFFFFFFC);
if ((pBaseCmd->nHasBits & 1) != 0)
nHasBits = static_cast<uint32_t>(nHasBits);
using fnWriteMessage = void(__fastcall*)(std::uintptr_t*, CUtlBuffer, int);
static const fnWriteMessage oWriteMessage = reinterpret_cast<fnWriteMessage>(M::FindPattern(CLIENT_DLL, "48 89 5C 24 10 48 89 6C 24 18 48 89 7C 24 20 41 56 48 83 EC 20 48 BF"));
using fnSetMessageData = std::string* (__fastcall*)(void*, std::uintptr_t*, void*);
static const fnSetMessageData oSetMessageData = reinterpret_cast<fnSetMessageData>(M::FindPattern(CLIENT_DLL, "48 89 5C 24 20 55 56 57 48 83 EC 30 49"));
oWriteMessage(pMessage, protobufBuffer, nCalcualtedCRCSize);
pBaseCmd->strMoveCrc = oSetMessageData(&pBaseCmd->strMoveCrc, pMessage, &nHasBits);
I::MemAlloc->Free(pMessage);
return true;
}
return false;
}
}

View File

@@ -0,0 +1,247 @@
#include "CheatMenu.h"
VOID MenuESP()
{
ImGui::PushItemWidth(220.0f);
// Enable Box ESP
ImGui::Text(("Box ESP"));
ImGui::Separator();
ImGui::Checkbox(("Enable"), &MenuConfig::ShowBoxESP);
ImGui::SameLine(200);
ImGui::Text(("Visible:"));
ImGui::SameLine(270);
ImGui::ColorEdit4(("##BoxColorVisible"), reinterpret_cast<float*>(&MenuConfig::BoxColorVisible), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::SameLine(360);
ImGui::Text(("Not Visible:"));
ImGui::SameLine(460);
ImGui::ColorEdit4(("##BoxColorNotVisible"), reinterpret_cast<float*>(&MenuConfig::BoxColorNotVisible), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::Text(("Thickness:"));
ImGui::SameLine(270);
ImGui::SliderFloat(("##BoxThickness"), &MenuConfig::BoxThickness, 0.5f, 2.0f, "%.2f");
ImGui::Spacing();
ImGui::Spacing();
ImGui::Text(("Bone ESP"));
ImGui::Separator();
ImGui::Checkbox(("Enable"), &MenuConfig::ShowBoneESP);
ImGui::SameLine(200);
ImGui::Text(("Visible:"));
ImGui::SameLine(270);
ImGui::ColorEdit4(("##BoneColorVisible"), reinterpret_cast<float*>(&MenuConfig::BoneColorVisible), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::SameLine(360);
ImGui::Text(("Not Visible:"));
ImGui::SameLine(460);
ImGui::ColorEdit4(("##BoneColorNotVisible"), reinterpret_cast<float*>(&MenuConfig::BoneColorNotVisible), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::Text(("Thickness:"));
ImGui::SameLine(270);
ImGui::SliderFloat(("##BoneThickness"), &MenuConfig::BoneThickness, 0.5f, 2.0f, "%.2f");
ImGui::Spacing();
ImGui::Spacing();
ImGui::Text(("Other ESP"));
ImGui::Separator();
ImGui::Checkbox(("Health ESP"), &MenuConfig::ShowHealthBar);
ImGui::Checkbox(("Distance ESP"), &MenuConfig::ShowDistance);
ImGui::SameLine(200);
ImGui::ColorEdit4(("##DistanceColor"), reinterpret_cast<float*>(&MenuConfig::DistanceColor), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::Checkbox(("Weapon ESP"), &MenuConfig::ShowWeaponESP);
ImGui::SameLine(200);
ImGui::ColorEdit4(("##WeaponColor"), reinterpret_cast<float*>(&MenuConfig::WeaponColor), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::Checkbox(("Name ESP"), &MenuConfig::ShowPlayerName);
ImGui::SameLine(200);
ImGui::ColorEdit4(("##NameColor"), reinterpret_cast<float*>(&MenuConfig::NameColor), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::Checkbox(("Item ESP"), &MenuConfig::ItemESP);
ImGui::SameLine(200);
ImGui::ColorEdit4(("##ItemColor"), reinterpret_cast<float*>(&MenuConfig::ItemColor), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::PopItemWidth();
}
VOID MenuAimBot()
{
ImGui::PushItemWidth(220.0f);
// Aimbot settings
ImGui::Text(("Aimbot Settings"));
ImGui::Separator();
ImGui::Checkbox(("Enable Aimbot"), &MenuConfig::EnableAimbot);
if (MenuConfig::EnableAimbot)
MenuConfig::StandloneRCS = false;
ImGui::Checkbox(("Standlone RCS"), &MenuConfig::StandloneRCS);
ImGui::Spacing();
ImGui::Spacing();
ImGui::SliderFloat("Vertical Recoil Control (RCS_Y)", &MenuConfig::RCS_Y, 0.0f, 5.0f, "%.2f");
ImGui::SliderFloat("Horizontal Recoil Control (RCS_X)", &MenuConfig::RCS_X, 0.0f, 5.0f, "%.2f");
// Bone selection
ImGui::Text(("Bone Selection"));
ImGui::Separator();
if (ImGui::Combo(("Visible Bone"), &MenuConfig::CurrentBoneIndex, Bones, IM_ARRAYSIZE(Bones)))
{
BONEINDEX SelectedBoneIndex = BoneIndexMap[MenuConfig::CurrentBoneIndex];
MenuConfig::SelectedBoneIndex = SelectedBoneIndex;
}
ImGui::Checkbox(("Aim Closest Visible Bone to FOV"), &MenuConfig::TargetClosestVisibleBoneToFov);
ImGui::Spacing();
ImGui::Spacing();
// Aimbot parameters
ImGui::Text(("Aimbot Parameters"));
ImGui::Separator();
ImGui::SliderFloat(("Smoothness"), &MenuConfig::AimSmoothness, 1.0f, 10.0f);
ImGui::SliderFloat(("FOV"), &MenuConfig::FOV, 1.0f, 1000.0f);
ImGui::Checkbox(("Draw FOV"), &MenuConfig::DrawFOV);
ImGui::Spacing();
ImGui::Spacing();
// Hotkey selection
ImGui::Text(("Hotkey"));
ImGui::Separator();
if (ImGui::Combo(("AimKey"), &CurrentHotkey, HotKeys, IM_ARRAYSIZE(HotKeys)))
MenuConfig::SelectedHotkey = CurrentHotkey;
ImGui::Spacing();
ImGui::Spacing();
// Silent Aim
ImGui::Text(("Additional Settings"));
ImGui::Separator();
ImGui::Checkbox(("Silent Aim"), &MenuConfig::EnableSilentAim);
ImGui::PopItemWidth();
}
VOID Miscellaneous()
{
ImGui::Checkbox("Light Changer", &MenuConfig::LightChanger);
if (MenuConfig::LightChanger)
{
ImGui::Begin("Miscellaneous Settings", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::PushItemWidth(220.0f);
// Section: Lighting Settings
ImGui::Text("Lighting Settings:");
ImGui::Separator();
ImGui::Text("Color:");
ImGui::SameLine();
ImGui::ColorEdit4("##LightingColor", (float*)&MenuConfig::wModulation.LightingColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_PickerHueWheel);
ImGui::Text("Intensity:");
ImGui::SameLine();
ImGui::SliderFloat("##LightingIntensity", &MenuConfig::wModulation.LightingIntensity, -10.0f, 10.0f);
ImGui::Spacing();
ImGui::Separator();
ImGui::Text("Skybox Color Settings:");
ImGui::Separator();
static float Hue = 0.0f;
ImGui::SliderFloat("Hue", &Hue, 0.0f, 1.0f, "%.2f");
ImVec4 RGBColor = ImColor::HSV(Hue, 1.0f, 1.0f);
MenuConfig::g_SkyboxColor.x = RGBColor.x;
MenuConfig::g_SkyboxColor.y = RGBColor.y;
MenuConfig::g_SkyboxColor.z = RGBColor.z;
ImGui::PopItemWidth();
ImGui::End();
}
ImGui::Text("Smoke Color Settings:");
ImGui::Separator();
ImGui::Checkbox("Enable Smoke Color", &MenuConfig::EnableSmokeColor);
if (MenuConfig::EnableSmokeColor)
ImGui::ColorEdit4("##SmokeColorPicker", (float*)&MenuConfig::SmokeColorPicker);
ImGui::Text("TriggerBot Settings:");
ImGui::Checkbox("Enable TriggerBot", &MenuConfig::TriggerBot);
ImGui::SliderFloat("Distance Threshold", &MenuConfig::TriggerbotDistanceThreshold, 0.0f, 250.0f, "%.1f");
ImGui::SliderFloat("Angle Tolerance", &MenuConfig::TriggerbotAngleTolerance, 0.0f, 150.0f, "%.1f");
ImGui::Text("Leave them on default if you don't understand what they do:");
}
VOID __fastcall RenderUI()
{
ImVec4 backgroundColor = ImVec4(0.05f, 0.1f, 0.15f, 1.0f);
ImGui::StyleColorsDark();
ImGuiStyle& style = ImGui::GetStyle();
style.Colors[ImGuiCol_Button] = ImVec4(0.15f, 0.3f, 0.2f, 1.0f);
style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.15f, 0.3f, 0.2f, 1.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, backgroundColor);
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, backgroundColor);
ImGui::PushStyleColor(ImGuiCol_TitleBgCollapsed, backgroundColor);
ImGui::SetNextWindowSize(ImVec2(650, 490));
ImGui::SetNextWindowBgAlpha(0.90f);
ImGuiWindowFlags WindowFlags =
ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoResize;
ImGui::PushFont(CustomFont);
if (MenuConfig::ShowMenu)
{
ImVec2 MenuSize = ImVec2(1000, 1000);
ImGui::Begin(("CS2 INTERNAL"), nullptr, WindowFlags);
if (ImGui::Button(("ESP"), ImVec2(185, 0))) MenuConfig::MenuState = 1;
ImGui::SameLine();
if (ImGui::Button(("Aimbot"), ImVec2(185, 0))) MenuConfig::MenuState = 2;
ImGui::SameLine();
if (ImGui::Button(("Miscellaneous"), ImVec2(215, 0))) MenuConfig::MenuState = 3;
switch (MenuConfig::MenuState)
{
case 1:
ImGui::SetWindowSize(MenuSize);
MenuESP();
break;
case 2:
ImGui::SetWindowSize(MenuSize);
MenuAimBot();
break;
case 3:
ImGui::SetWindowSize(MenuSize);
Miscellaneous();
break;
default:
break;
}
ImGui::End();
}
ImGui::PopFont();
ImGui::PopStyleColor(3);
}

View File

@@ -0,0 +1,123 @@
#pragma once
#include "Bones.h"
#include "D3D.h"
inline int CurrentHotkey;
namespace MenuConfig
{
inline bool ShowBoneESP = true;
inline bool ShowBoxESP = true;
inline bool ShowHealthBar = true;
inline int SelectedHotkey;
inline bool ShowWeaponESP = true;
inline bool StandloneRCS = false;
inline int SelectedBoneIndex;
inline bool BunnyHop = false;
inline bool AutoStrafe = false;
inline bool EnableAimbot = false;
inline bool EnableSilentAim = false;
inline bool TargetClosestVisibleBoneToFov = false;
inline bool ShowDistance = true;
inline bool ItemESP = true;
inline bool ShowPlayerName = true;
inline bool DrawFOV = false;
inline bool TriggerBot = false;
inline ImColor BoneColorVisible = ImColor(255, 0, 0, 255); // Red for visible
inline ImColor BoneColorNotVisible = ImColor(0, 255, 0, 255); // Green for not visible
inline ImColor BoxColorVisible = ImColor(255, 0, 0, 255); // Red for visible
inline ImColor BoxColorNotVisible = ImColor(0, 255, 0, 255); // Green for not visible
inline ImColor ItemColor = ImColor(255, 255, 255, 255); // Cyan
inline ImColor NameColor = ImColor(255, 255, 255, 255); // Yellow
inline ImColor WeaponColor = ImColor(255, 255, 255, 255); // White
inline ImColor DistanceColor = ImColor(255, 255, 255, 255); // Orange
inline float BoxThickness = 1.55f;
inline float BoneThickness = 1.55f;
inline float AimSmoothness = 1.0f;
inline float RCS_Y = 2.55f;
inline float RCS_X = 2.40f;
inline bool ClosestBone = false;
inline int CurrentBoneIndex = 6;
inline float FOV = 100.0f;;
inline bool ShowMenu = true;
inline int MenuState = 1;
inline bool ShowTimer = true;
inline float TriggerbotDistanceThreshold = 155.0f;
inline float TriggerbotAngleTolerance = 55.0f;
inline bool LightChanger = false;
inline bool EnableSmokeColor = false;
inline ImVec4 g_SkyboxColor = ImVec4(1.0f, 0.75f, 0.8f, 1.0f);
inline Vector_t SmokeColorPicker = Vector_t(1.0f, 0.0f, 0.0f); // Default to red
inline struct WorldModulation
{
ImVec4 LightingColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
float LightingIntensity = 1.0f;
} wModulation;
}
inline const char* HotKeys[] =
{
"Shift", "Alt" ,
"Left Mouse Button" , "Right Mouse Button" , "Middle Mouse Button" ,
"Mouse Button 4" , "Mouse Button 5"
};
inline int HotKeyCodes[] =
{
VK_SHIFT, // "Shift"
VK_MENU, // "Alt"
VK_LBUTTON, // "Left Mouse Button"
VK_RBUTTON, // "Right Mouse Button"
VK_MBUTTON, // "Middle Mouse Button"
VK_XBUTTON1, // "Mouse Button 4"
VK_XBUTTON2, // "Mouse Button 5"
};
inline const char* Bones[] =
{
"Head", // head = 6
"Neck", // neck_0 = 5
"Spine 1", // spine_1 = 4
"Spine 2", // spine_2 = 2
"Pelvis", // pelvis = 0
"Left Upper Arm", // arm_upper_L = 8
"Left Lower Arm", // arm_lower_L = 9
"Left Hand", // hand_L = 10
"Right Upper Arm", // arm_upper_R = 13
"Right Lower Arm", // arm_lower_R = 14
"Right Hand", // hand_R = 15
"Left Upper Leg", // leg_upper_L = 22
"Left Lower Leg", // leg_lower_L = 23
"Left Ankle", // ankle_L = 24
"Right Upper Leg", // leg_upper_R = 25
"Right Lower Leg", // leg_lower_R = 26
"Right Ankle" // ankle_R = 27
};
inline BONEINDEX BoneIndexMap[] =
{
BONEINDEX::Head, // 0 "Head" maps to BONEINDEX::Head (6)
BONEINDEX::Neck_0, // 1 "Neck" maps to BONEINDEX::Neck_0 (5)
BONEINDEX::Spine_1, // 2 "Spine 1" maps to BONEINDEX::Spine_1 (4)
BONEINDEX::Spine_2, // 3 "Spine 2" maps to BONEINDEX::Spine_2 (2)
BONEINDEX::Pelvis, // 4 "Pelvis" maps to BONEINDEX::Pelvis (0)
BONEINDEX::Arm_Upper_L, // 5 "Left Upper Arm" maps to BONEINDEX::Arm_Upper_L (8)
BONEINDEX::Arm_Lower_L, // 6 "Left Lower Arm" maps to BONEINDEX::Arm_Lower_L (9)
BONEINDEX::Hand_L, // 7 "Left Hand" maps to BONEINDEX::Hand_L (10)
BONEINDEX::Arm_Upper_R, // 8 "Right Upper Arm" maps to BONEINDEX::Arm_Upper_R (13)
BONEINDEX::Arm_Lower_R, // 9 "Right Lower Arm" maps to BONEINDEX::Arm_Lower_R (14)
BONEINDEX::Hand_R, // 10 "Right Hand" maps to BONEINDEX::Hand_R (15)
BONEINDEX::Leg_Upper_L, // 11 "Left Upper Leg" maps to BONEINDEX::Leg_Upper_L (22)
BONEINDEX::Leg_Lower_L, // 12 "Left Lower Leg" maps to BONEINDEX::Leg_Lower_L (23)
BONEINDEX::Ankle_L, // 13 "Left Ankle" maps to BONEINDEX::Ankle_L (24)
BONEINDEX::Leg_Upper_R, // 14 "Right Upper Leg" maps to BONEINDEX::Leg_Upper_R (25)
BONEINDEX::Leg_Lower_R, // 15 "Right Lower Leg" maps to BONEINDEX::Leg_Lower_R (26)
BONEINDEX::Ankle_R // 16 "Right Ankle" maps to BONEINDEX::Ankle_R (27)
};
VOID MenuESP();
VOID MenuAimBot();
VOID RenderUI();

View File

@@ -0,0 +1,245 @@
#pragma once
#include "cstdint"
#include "ImGui/imgui.h"
#include "bit"
#include <cmath>
#include "limits"
enum
{
COLOR_R = 0,
COLOR_G = 1,
COLOR_B = 2,
COLOR_A = 3
};
struct ColorRGBExp32
{
std::uint8_t r, g, b;
std::int8_t iExponent;
};
template <class T>
inline constexpr std::remove_reference_t<T>&& Move(T&& argument) noexcept
{
return static_cast<std::remove_reference_t<T>&&>(argument);
}
template <typename T>
requires (std::is_move_constructible_v<T>&& std::is_move_assignable_v<T>)
inline constexpr void Swap(T& left, T& right) noexcept(std::is_nothrow_move_constructible_v<T>&& std::is_nothrow_move_assignable_v<T>)
{
T temporary = Move(left);
left = Move(right);
right = Move(temporary);
}
template <typename T>
inline constexpr const T& Min(const T& left, const T& right) noexcept
{
return (right < left) ? right : left;
}
static_assert(sizeof(ColorRGBExp32) == 0x4);
struct Color_t
{
Color_t() = default;
// 8-bit color constructor (in: [0 .. 255])
constexpr Color_t(const std::uint8_t r, const std::uint8_t g, const std::uint8_t b, const std::uint8_t a = 255) :
r(r), g(g), b(b), a(a) { }
// 8-bit color constructor (in: [0 .. 255])
constexpr Color_t(const int r, const int g, const int b, const int a = 255) :
r(static_cast<std::uint8_t>(r)), g(static_cast<std::uint8_t>(g)), b(static_cast<std::uint8_t>(b)), a(static_cast<std::uint8_t>(a)) { }
// 8-bit array color constructor (in: [0.0 .. 1.0])
explicit constexpr Color_t(const std::uint8_t arrColor[4]) :
r(arrColor[COLOR_R]), g(arrColor[COLOR_G]), b(arrColor[COLOR_B]), a(arrColor[COLOR_A]) { }
// 32-bit packed color constructor (in: 0x00000000 - 0xFFFFFFFF)
explicit constexpr Color_t(const ImU32 uPackedColor) :
r(static_cast<std::uint8_t>((uPackedColor >> IM_COL32_R_SHIFT) & 0xFF)), g(static_cast<std::uint8_t>((uPackedColor >> IM_COL32_G_SHIFT) & 0xFF)), b(static_cast<std::uint8_t>((uPackedColor >> IM_COL32_B_SHIFT) & 0xFF)), a(static_cast<std::uint8_t>((uPackedColor >> IM_COL32_A_SHIFT) & 0xFF)) { }
// 32-bit color constructor (in: [0.0 .. 1.0])
constexpr Color_t(const float r, const float g, const float b, const float a = 1.0f) :
r(static_cast<std::uint8_t>(r * 255.f)), g(static_cast<std::uint8_t>(g * 255.f)), b(static_cast<std::uint8_t>(b * 255.f)), a(static_cast<std::uint8_t>(a * 255.f)) { }
/// @returns: 32-bit packed integer representation of color
[[nodiscard]] constexpr ImU32 GetU32(const float flAlphaMultiplier = 1.0f) const
{
return IM_COL32(r, g, b, a * flAlphaMultiplier);
}
/// @return: converted color to imgui vector
[[nodiscard]] ImVec4 GetVec4(const float flAlphaMultiplier = 1.0f) const
{
return ImVec4(this->Base<COLOR_R>(), this->Base<COLOR_G>(), this->Base<COLOR_B>(), this->Base<COLOR_A>() * flAlphaMultiplier);
}
std::uint8_t& operator[](const std::uint8_t nIndex)
{
return reinterpret_cast<std::uint8_t*>(this)[nIndex];
}
const std::uint8_t& operator[](const std::uint8_t nIndex) const
{
return reinterpret_cast<const std::uint8_t*>(this)[nIndex];
}
bool operator==(const Color_t& colSecond) const
{
return (std::bit_cast<std::uint32_t>(*this) == std::bit_cast<std::uint32_t>(colSecond));
}
bool operator!=(const Color_t& colSecond) const
{
return (std::bit_cast<std::uint32_t>(*this) != std::bit_cast<std::uint32_t>(colSecond));
}
/// @returns: copy of color with certain R/G/B/A component changed to given value
template <std::size_t N>
[[nodiscard]] Color_t Set(const std::uint8_t nValue) const
{
static_assert(N >= COLOR_R && N <= COLOR_A, "color component index is out of range");
Color_t colCopy = *this;
colCopy[N] = nValue;
return colCopy;
}
/// @returns: copy of color with certain R/G/B/A component multiplied by given value
template <std::size_t N>
[[nodiscard]] Color_t Multiplier(const float flValue) const
{
static_assert(N >= COLOR_R && N <= COLOR_A, "color component index is out of range");
Color_t colCopy = *this;
colCopy[N] = static_cast<std::uint8_t>(static_cast<float>(colCopy[N]) * flValue);
return colCopy;
}
/// @returns: copy of color with certain R/G/B/A component divided by given value
template <std::size_t N>
[[nodiscard]] Color_t Divider(const int iValue) const
{
static_assert(N >= COLOR_R && N <= COLOR_A, "color component index is out of range");
Color_t colCopy = *this;
colCopy[N] /= iValue;
return colCopy;
}
/// @returns: certain R/G/B/A float value (in: [0 .. 255], out: [0.0 .. 1.0])
template <std::size_t N>
[[nodiscard]] float Base() const
{
static_assert(N >= COLOR_R && N <= COLOR_A, "color component index is out of range");
return reinterpret_cast<const std::uint8_t*>(this)[N] / 255.f;
}
/// @param[out] arrBase output array of R/G/B color components converted to float (in: [0 .. 255], out: [0.0 .. 1.0])
constexpr void Base(float(&arrBase)[3]) const
{
arrBase[COLOR_R] = static_cast<float>(r) / 255.f;
arrBase[COLOR_G] = static_cast<float>(g) / 255.f;
arrBase[COLOR_B] = static_cast<float>(b) / 255.f;
}
/// @returns: color created from float[3] array (in: [0.0 .. 1.0], out: [0 .. 255])
static Color_t FromBase3(const float arrBase[3])
{
return { arrBase[0], arrBase[1], arrBase[2] };
}
/// @param[out] arrBase output array of R/G/B/A color components converted to float (in: [0 .. 255], out: [0.0 .. 1.0])
constexpr void BaseAlpha(float(&arrBase)[4]) const
{
arrBase[COLOR_R] = static_cast<float>(r) / 255.f;
arrBase[COLOR_G] = static_cast<float>(g) / 255.f;
arrBase[COLOR_B] = static_cast<float>(b) / 255.f;
arrBase[COLOR_A] = static_cast<float>(a) / 255.f;
}
static Color_t FromBase4(const float arrBase[4])
{
return { arrBase[COLOR_R], arrBase[COLOR_G], arrBase[COLOR_B], arrBase[COLOR_A] };
}
void ToHSB(float(&arrHSB)[3]) const
{
float arrBase[3] = {};
Base(arrBase);
float flKernel = 0.0f;
if (arrBase[COLOR_G] < arrBase[COLOR_B])
{
Swap(arrBase[COLOR_G], arrBase[COLOR_B]);
flKernel = -1.0f;
}
if (arrBase[COLOR_R] < arrBase[COLOR_G])
{
Swap(arrBase[COLOR_R], arrBase[COLOR_G]);
flKernel = -2.0f / 6.0f - flKernel;
}
const float flChroma = arrBase[COLOR_R] - Min(arrBase[COLOR_G], arrBase[COLOR_B]);
arrHSB[COLOR_R] = std::fabsf(flKernel + (arrBase[COLOR_G] - arrBase[COLOR_B]) / (6.0f * flChroma + std::numeric_limits<float>::epsilon()));
arrHSB[COLOR_G] = flChroma / (arrBase[COLOR_R] + std::numeric_limits<float>::epsilon());
arrHSB[COLOR_G] = arrBase[COLOR_R];
}
static Color_t FromHSB(const float flHue, const float flSaturation, const float flBrightness, const float flAlpha = 1.0f)
{
constexpr float flHueRange = (60.0f / 360.0f);
const float flHuePrime = std::fmodf(flHue, 1.0f) / flHueRange;
const int iRoundHuePrime = static_cast<int>(flHuePrime);
const float flDelta = flHuePrime - static_cast<float>(iRoundHuePrime);
const float p = flBrightness * (1.0f - flSaturation);
const float q = flBrightness * (1.0f - flSaturation * flDelta);
const float t = flBrightness * (1.0f - flSaturation * (1.0f - flDelta));
float flRed, flGreen, flBlue;
switch (iRoundHuePrime)
{
case 0:
flRed = flBrightness;
flGreen = t;
flBlue = p;
break;
case 1:
flRed = q;
flGreen = flBrightness;
flBlue = p;
break;
case 2:
flRed = p;
flGreen = flBrightness;
flBlue = t;
break;
case 3:
flRed = p;
flGreen = q;
flBlue = flBrightness;
break;
case 4:
flRed = t;
flGreen = p;
flBlue = flBrightness;
break;
default:
flRed = flBrightness;
flGreen = p;
flBlue = q;
break;
}
return { flRed, flGreen, flBlue, flAlpha };
}
std::uint8_t r = 0U, g = 0U, b = 0U, a = 0U;
};

View File

@@ -0,0 +1,87 @@
#include "d3d.h"
void InitiateImGui()
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
CustomFont = io.Fonts->AddFontFromMemoryTTF(Ubuntu, sizeof(Ubuntu), 15.0f);
WeaponFont = io.Fonts->AddFontFromMemoryTTF(WeaponImages, sizeof(WeaponImages), 20.0f);
ProjectileFont = io.Fonts->AddFontFromMemoryTTF(WeaponImages, sizeof(WeaponImages), 45.0f);
TimerFont = io.Fonts->AddFontFromMemoryTTF(Ubuntu, sizeof(Ubuntu), 45.0f);
DefuseKitFont = io.Fonts->AddFontFromMemoryTTF(WeaponImages, sizeof(WeaponImages), 30.0f);
ImGui_ImplWin32_Init(Window);
ImGui_ImplDX11_Init(pDevice, pContext);
io.Fonts->TexDesiredWidth = 1024;
io.Fonts->Build();
ID3D11ShaderResourceView* fontTexture = nullptr;
io.Fonts->TexID = (void*)fontTexture;
}
LRESULT WINAPI WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam))
return true;
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
}
VOID DrawFov()
{
if (!MenuConfig::DrawFOV)
return;
ImDrawList* draw_list = ImGui::GetBackgroundDrawList();
float screenWidth = ImGui::GetIO().DisplaySize.x;
float screenHeight = ImGui::GetIO().DisplaySize.y;
ImVec2 center(screenWidth / 2.0f, screenHeight / 2.0f);
draw_list->AddCircle(center, MenuConfig::FOV, IM_COL32(255, 255, 255, 255), 64, 2.0f);
}
HRESULT WINAPI hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
if (!Initiated)
{
if (SUCCEEDED(pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&pDevice)))
{
pDevice->GetImmediateContext(&pContext);
DXGI_SWAP_CHAIN_DESC sd;
pSwapChain->GetDesc(&sd);
Window = sd.OutputWindow;
ID3D11Texture2D* pBackBuffer;
pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &MainRenderTargetView);
pBackBuffer->Release();
oWndProc = (WNDPROC)SetWindowLongPtr(Window, GWLP_WNDPROC, (LONG_PTR)WndProc);
InitiateImGui();
Initiated = true;
}
else
return oPresent(pSwapChain, SyncInterval, Flags);
}
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
if (GetAsyncKeyState(VK_INSERT) & 1)
MenuConfig::ShowMenu = !MenuConfig::ShowMenu;
RenderUI();
RenderESP();
DrawFov();
ImGui::Render();
pContext->OMSetRenderTargets(1, &MainRenderTargetView, NULL);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
return oPresent(pSwapChain, SyncInterval, Flags);
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include <d3d11.h>
#include "ImGui/imgui.h"
#include "ImGui/imgui_impl_dx11.h"
#include "ImGui/imgui_impl_win32.h"
#include "WeaponFont.h"
#include "TextFont.h"
#include "CheatMenu.h"
#include "ESP.h"
#include "cGameEntitySystem.h"
#include "detour.h"
LRESULT WINAPI WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
VOID InitiateImGui();
typedef HRESULT(__stdcall* Present) (IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
inline Present oPresent;
HRESULT WINAPI hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
inline LRESULT WINAPI WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
inline WNDPROC oWndProc;
inline HWND Window = 0;
inline ID3D11Device* pDevice = 0;
inline ID3D11DeviceContext* pContext = 0;
inline ID3D11RenderTargetView* MainRenderTargetView;
inline bool g_WantUpdateHasGamepad = true;
inline bool Initiated = false;
inline ImFont* CustomFont = nullptr;
inline ImFont* WeaponFont = nullptr;
inline ImFont* ProjectileFont = nullptr;
inline ImFont* DefuseKitFont = nullptr;
inline ImFont* TimerFont = nullptr;

View File

@@ -0,0 +1,43 @@
#include "Windows.h"
#include "Schema/SchemaSetup.h"
#include "Setup.h"
#include "Hooks.h"
#include "RenderHooks.h"
void AllocateConsole()
{
if (AllocConsole())
{
FILE* file;
freopen_s(&file, "CONOUT$", "w", stdout);
freopen_s(&file, "CONOUT$", "w", stderr);
freopen_s(&file, "CONIN$", "r", stdin);
SetConsoleTitle(L"My Application Console");
}
}
extern BOOL InitializeOffsets();
extern BOOL PresentHook();
BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
Setup();
SetupSchema("client.dll");
InitializeOffsets();
PresentHook();
Hooks::VirtualTable();
Hooks::Detours();
return true;
}
}

View File

@@ -0,0 +1,310 @@
#include "ESP.h"
#include "iEngineClient.h"
Vector4D_t Get2DBox(Vector_t WorldPosition, const float Height)
{
Vector_t TopPos3D;
TopPos3D = WorldPosition;
TopPos3D.z += Height;
Vector2D_t GroundPos2D, TopPos2D;
if (!View.WorldToScreen(WorldPosition, GroundPos2D) || !View.WorldToScreen(TopPos3D, TopPos2D))
return Vector4D_t{ 0.0f, 0.0f, 0.0f, 0.0f };
if (TopPos2D.y < 0.0f || GroundPos2D.y > ImGui::GetIO().DisplaySize.y)
return Vector4D_t{ 0.0f, 0.0f, 0.0f, 0.0f };
Vector2D_t Size, Pos;
Size.y = std::abs(TopPos2D.y - GroundPos2D.y);
Size.x = Size.y * 0.60;
Pos.x = GroundPos2D.x - Size.x / 2;
Pos.y = TopPos2D.y;
return Vector4D_t{ Pos.x, Pos.y, Size.x, Size.y };
}
inline void DrawCustomBox(const ImVec2& rect_min, const ImVec2& rect_max, const ImColor& boxColor, float borderThickness, float cornerLength = 10.0f)
{
ImDrawList* draw_list = ImGui::GetBackgroundDrawList();
// Top Left Corner
draw_list->AddLine(ImVec2(rect_min.x, rect_min.y), ImVec2(rect_min.x + cornerLength, rect_min.y), boxColor, borderThickness);
draw_list->AddLine(ImVec2(rect_min.x, rect_min.y), ImVec2(rect_min.x, rect_min.y + cornerLength), boxColor, borderThickness);
// Top Right Corner
draw_list->AddLine(ImVec2(rect_max.x, rect_min.y), ImVec2(rect_max.x - cornerLength, rect_min.y), boxColor, borderThickness);
draw_list->AddLine(ImVec2(rect_max.x, rect_min.y), ImVec2(rect_max.x, rect_min.y + cornerLength), boxColor, borderThickness);
// Bottom Left Corner
draw_list->AddLine(ImVec2(rect_min.x, rect_max.y), ImVec2(rect_min.x + cornerLength, rect_max.y), boxColor, borderThickness);
draw_list->AddLine(ImVec2(rect_min.x, rect_max.y), ImVec2(rect_min.x, rect_max.y - cornerLength), boxColor, borderThickness);
// Bottom Right Corner
draw_list->AddLine(ImVec2(rect_max.x, rect_max.y), ImVec2(rect_max.x - cornerLength, rect_max.y), boxColor, borderThickness);
draw_list->AddLine(ImVec2(rect_max.x, rect_max.y), ImVec2(rect_max.x, rect_max.y - cornerLength), boxColor, borderThickness);
}
inline void DrawHealthBar(float MaxHealth, float CurrentHealth, ImVec2 Pos, ImVec2 Size, bool Horizontal)
{
ImDrawList* DrawList = ImGui::GetBackgroundDrawList();
float Proportion = CurrentHealth / MaxHealth;
ImColor FirstStageColor = ImColor(96, 246, 113, 220);
ImColor SecondStageColor = ImColor(247, 214, 103, 220);
ImColor ThirdStageColor = ImColor(255, 95, 95, 220);
ImColor BackGroundColor = ImColor(90, 90, 90, 220);
ImColor Color;
if (Proportion > 0.5)
Color = FirstStageColor;
else if (Proportion > 0.25)
Color = SecondStageColor;
else
Color = ThirdStageColor;
DrawList->AddRectFilled(Pos, { Pos.x + Size.x, Pos.y + Size.y }, BackGroundColor);
if (Horizontal)
DrawList->AddRectFilled(Pos, { Pos.x + Size.x * Proportion, Pos.y + Size.y }, Color);
else
{
float healthHeight = Size.y * Proportion;
DrawList->AddRectFilled({ Pos.x, Pos.y + Size.y - healthHeight }, { Pos.x + Size.x, Pos.y + Size.y }, Color);
}
ImColor BorderColor = ImColor(45, 45, 45, 220);
DrawList->AddRect(Pos, { Pos.x + Size.x, Pos.y + Size.y }, BorderColor);
}
inline void DrawBone(const CBone& BoneData, float Thickness)
{
if (BoneData.BonePositions.empty())
return;
ImDrawList* DrawList = ImGui::GetBackgroundDrawList();
for (const auto& BoneList : BoneJointList::List)
{
const BonePosition* Previous = nullptr;
for (const auto& i : BoneList)
{
if (i >= BoneData.BonePositions.size())
continue;
const BonePosition& Current = BoneData.BonePositions[i];
if (Previous != nullptr && Previous->WorldVisible && Current.WorldVisible && !Current.RayTraceVisible)
DrawList->AddLine(ImVec2(Previous->ScreenPosition.x, Previous->ScreenPosition.y), ImVec2(Current.ScreenPosition.x, Current.ScreenPosition.y), MenuConfig::BoneColorNotVisible, Thickness);
else if (Previous != nullptr && Previous->WorldVisible && Current.WorldVisible && Current.RayTraceVisible)
DrawList->AddLine(ImVec2(Previous->ScreenPosition.x, Previous->ScreenPosition.y), ImVec2(Current.ScreenPosition.x, Current.ScreenPosition.y), MenuConfig::BoneColorVisible, Thickness);
Previous = &Current;
}
}
}
VOID __fastcall RenderESP()
{
ImGui::PushFont(CustomFont);
if (!I::Engine->IsConnected() || !I::Engine->IsInGame())
return;
for (const auto& Entity : *CurrentPlayerList)
{
ImVec2 Rect_Min = ImVec2(Entity.Pawn.Rectangle.x, Entity.Pawn.Rectangle.y);
ImVec2 Rect_Max = ImVec2(Entity.Pawn.Rectangle.x + Entity.Pawn.Rectangle.z, Entity.Pawn.Rectangle.y + Entity.Pawn.Rectangle.w);
if (MenuConfig::ShowBoxESP)
DrawCustomBox(Rect_Min, Rect_Max, Entity.Pawn.isVisible ? MenuConfig::BoxColorVisible : MenuConfig::BoxColorNotVisible, MenuConfig::BoxThickness);
if (MenuConfig::ShowBoneESP)
DrawBone(Entity.Pawn.BoneData, MenuConfig::BoneThickness);
if (MenuConfig::ShowHealthBar)
{
ImVec2 HealthBarPos = { Entity.Pawn.Rectangle.x - 7.0f, Entity.Pawn.Rectangle.y };
ImVec2 HealthBarSize = { 4.0f, Entity.Pawn.Rectangle.w };
DrawHealthBar(100, Entity.Pawn.Health, HealthBarPos, HealthBarSize, false);
}
if (MenuConfig::ShowPlayerName)
{
ImVec2 TextSize = ImGui::CalcTextSize(Entity.Controller.m_sSanitizedPlayerName.c_str());
ImVec2 TextPos = { Entity.Pawn.Rectangle.x + Entity.Pawn.Rectangle.z / 2 - TextSize.x / 2, Entity.Pawn.Rectangle.y - 22 };
ImGui::GetForegroundDrawList()->AddText(TextPos, MenuConfig::NameColor, Entity.Controller.m_sSanitizedPlayerName.c_str());
}
if (MenuConfig::ShowDistance)
{
float DistanceToLocal = SDK::LocalPawn->GetOrigin().DistTo(Entity.Pawn.m_vOldOrigin) * 0.0254;
int RoundedDistance = static_cast<int>(std::floor(DistanceToLocal));
std::string DistanceText = std::to_string(RoundedDistance) + "m";
ImVec2 DistanceTextSize = ImGui::CalcTextSize(DistanceText.c_str());
ImVec2 DistanceTextPos = { Entity.Pawn.Rectangle.x + Entity.Pawn.Rectangle.z / 2 - DistanceTextSize.x / 2, Entity.Pawn.Rectangle.y - 35 };
ImGui::GetForegroundDrawList()->AddText(DistanceTextPos, MenuConfig::DistanceColor, DistanceText.c_str());
}
if (MenuConfig::ShowWeaponESP)
{
ImGui::PushFont(WeaponFont);
for (const auto& WeaponEntity : *CurrentWeaponList)
{
if (WeaponEntity.CSWeaponBase == Entity.Pawn.CSWeaponBase)
{
std::string WeaponIcon = GunIcon(WeaponEntity.Name);
ImVec2 TextSize = ImGui::CalcTextSize(WeaponIcon.c_str());
ImVec2 TextPosition = { Entity.Pawn.Rectangle.x + (Entity.Pawn.Rectangle.z - TextSize.x) * 0.5f, Entity.Pawn.Rectangle.y + Entity.Pawn.Rectangle.w + 5.0f};
ImGui::GetForegroundDrawList()->AddText(TextPosition, MenuConfig::WeaponColor, WeaponIcon.c_str());
break;
}
}
ImGui::PopFont();
}
}
for (const auto& Entity : *CurrentChickenList)
{
ImVec2 Rect_MinChicken = ImVec2(Entity.Chicken.Rectangle.x, Entity.Chicken.Rectangle.y);
ImVec2 Rect_MaxChicken = ImVec2(Entity.Chicken.Rectangle.x + Entity.Chicken.Rectangle.z, Entity.Chicken.Rectangle.y + Entity.Chicken.Rectangle.w);
DrawCustomBox(Rect_MinChicken, Rect_MaxChicken, Entity.Chicken.isVisible ? MenuConfig::BoxColorVisible : MenuConfig::BoxColorNotVisible, MenuConfig::BoxThickness);
ImVec2 TextSize = ImGui::CalcTextSize(Entity.Chicken.Name.c_str());
ImVec2 TextPos = { Entity.Chicken.Rectangle.x + Entity.Chicken.Rectangle.z / 2 - TextSize.x / 2, Entity.Chicken.Rectangle.y - 16 };
ImGui::GetForegroundDrawList()->AddText(TextPos, MenuConfig::NameColor, Entity.Chicken.Name.c_str());
float DistanceToLocal = SDK::LocalPawn->GetOrigin().DistTo(Entity.Chicken.WorldPosition) * 0.0254;
int RoundedDistance = static_cast<int>(std::floor(DistanceToLocal));
std::string DistanceText = std::to_string(RoundedDistance) + "m";
ImVec2 DistanceTextSize = ImGui::CalcTextSize(DistanceText.c_str());
ImVec2 DistanceTextPos = { Entity.Chicken.Rectangle.x + Entity.Chicken.Rectangle.z / 2 - DistanceTextSize.x / 2, Entity.Chicken.Rectangle.y + Entity.Chicken.Rectangle.w + 2.0f };
ImGui::GetForegroundDrawList()->AddText(DistanceTextPos, MenuConfig::DistanceColor, DistanceText.c_str());
}
ImGui::PopFont();
for (const auto& Entity : *CurrentWeaponList)
{
Vector2D_t ScreenPosition;
if (!View.WorldToScreen(Entity.WorldPosition, ScreenPosition))
continue;
if (ScreenPosition.x < 0.0f || ScreenPosition.x > ImGui::GetIO().DisplaySize.x ||
ScreenPosition.y < 0.0f || ScreenPosition.y > ImGui::GetIO().DisplaySize.y)
continue;
if (Entity.WorldPosition.x == 0 || Entity.WorldPosition.y == 0 || Entity.WorldPosition.z == 0)
continue;
ImVec2 IconTextSize;
if (Entity.Name == "CBaseAnimGraph" || Entity.Name == "C4")
{
ImGui::PushFont(DefuseKitFont);
std::string WeaponIcon = GunIcon(Entity.Name);
IconTextSize = ImGui::CalcTextSize(WeaponIcon.c_str());
ImGui::GetForegroundDrawList()->AddText(ImVec2(ScreenPosition.x - IconTextSize.x * 0.5f, ScreenPosition.y - IconTextSize.y * 0.5f), MenuConfig::ItemColor, WeaponIcon.c_str());
ImGui::PopFont();
ImVec2 NameTextSize = ImGui::CalcTextSize(Entity.Name.c_str());
ImGui::GetForegroundDrawList()->AddText(ImVec2(ScreenPosition.x - NameTextSize.x * 0.5f, ScreenPosition.y + IconTextSize.y * 0.5f + 2.0f), MenuConfig::ItemColor, Entity.Name.c_str());
}
else
{
ImGui::PushFont(WeaponFont);
std::string WeaponIcon = GunIcon(Entity.Name);
IconTextSize = ImGui::CalcTextSize(WeaponIcon.c_str());
ImGui::GetForegroundDrawList()->AddText(ImVec2(ScreenPosition.x - IconTextSize.x * 0.5f, ScreenPosition.y - IconTextSize.y * 0.5f), MenuConfig::ItemColor, WeaponIcon.c_str());
ImGui::PopFont();
ImVec2 NameTextSize = ImGui::CalcTextSize(Entity.Name.c_str());
ImGui::GetForegroundDrawList()->AddText(ImVec2(ScreenPosition.x - NameTextSize.x * 0.5f, ScreenPosition.y + IconTextSize.y * 0.5f + 2.0f), MenuConfig::ItemColor, Entity.Name.c_str());
}
float DistanceToLocal = SDK::LocalPawn->GetOrigin().DistTo(Entity.WorldPosition) * 0.0254;
int RoundedDistance = static_cast<int>(std::floor(DistanceToLocal));
std::string DistanceText = std::to_string(RoundedDistance) + "m";
ImVec2 DistanceTextSize = ImGui::CalcTextSize(DistanceText.c_str());
ImVec2 DistanceTextPos = { ScreenPosition.x - DistanceTextSize.x / 2, ScreenPosition.y - IconTextSize.y - DistanceTextSize.y - 2.0f };
ImGui::GetForegroundDrawList()->AddText(DistanceTextPos, MenuConfig::DistanceColor, DistanceText.c_str());
}
for (auto it = ActiveInfernoEntities.begin(); it != ActiveInfernoEntities.end();)
{
auto& [id, Entity] = *it;
C_Inferno* Molotov = reinterpret_cast<C_Inferno*>(Entity.Inferno.Base);
if (!Molotov || !Molotov->IsBurning()) {
it = ActiveInfernoEntities.erase(it);
continue;
}
auto Now = std::chrono::steady_clock::now();
auto ElapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(Now - Entity.StartTime).count();
int TotalDuration = 7000;
int RemainingTime = TotalDuration - ElapsedTime;
if (RemainingTime <= 0)
{
it = ActiveInfernoEntities.erase(it);
continue;
}
std::string WeaponIcon = GunIcon("MolotovGrenade");
ImVec2 TextSize = ImGui::CalcTextSize(WeaponIcon.c_str());
Vector2D_t ScreenPosition;
if (!View.WorldToScreen(Entity.Inferno.WorldPosition, ScreenPosition)) {
++it;
continue;
}
if (ScreenPosition.x < 0.0f || ScreenPosition.x > ImGui::GetIO().DisplaySize.x ||
ScreenPosition.y < 0.0f || ScreenPosition.y > ImGui::GetIO().DisplaySize.y) {
++it;
continue;
}
if (Entity.Inferno.WorldPosition.x == 0 || Entity.Inferno.WorldPosition.y == 0 || Entity.Inferno.WorldPosition.z == 0) {
++it;
continue;
}
ImGui::PushFont(ProjectileFont);
ImGui::GetForegroundDrawList()->AddText(ImVec2(ScreenPosition.x - TextSize.x * 0.5f, ScreenPosition.y - TextSize.y * 0.5f), MenuConfig::WeaponColor, WeaponIcon.c_str());
ImGui::PopFont();
float BarWidth = TextSize.x * 20.0f;
float Progress = static_cast<float>(RemainingTime) / static_cast<float>(TotalDuration);
ImVec2 BarPos = ImVec2(ScreenPosition.x - BarWidth * 0.5f + TextSize.x * 0.2f, ScreenPosition.y - TextSize.y - 5.0f);
ImVec2 BarEndPos = ImVec2(BarPos.x + BarWidth * Progress, BarPos.y + 5.0f);
ImU32 BarColor = ImColor::HSV(Progress * 0.33f, 1.0f, 1.0f);
ImGui::GetForegroundDrawList()->AddRectFilled(BarPos, BarEndPos, BarColor);
ImGui::GetForegroundDrawList()->AddRect(BarPos, ImVec2(BarPos.x + BarWidth, BarEndPos.y), IM_COL32(255, 255, 255, 255));
++it;
}
}

View File

@@ -0,0 +1,112 @@
#pragma once
#include "CheatMenu.h"
#include "W2S.h"
#include "map"
#include "Utils/Interfaces.h"
#include "chrono"
Vector4D_t Get2DBox(Vector_t WorldPosition, const float Height);
inline ImFont* CustomFontWeapon;
VOID __fastcall RenderESP();
inline const char* GunIcon(const std::string& weapon)
{
std::map<std::string, const char*> gunIcons =
{
{"P90", "P"},
{"MP9", "O"},
{"Mp5sd", "x"},
{"M4a4", "M"},
{"Knife", "]"},
{"DEagle", "A"},
{"Elite", "B"},
{"FiveSeven", "C"},
{"Glock", "D"},
{"Revolver", "J"},
{"HKP2000", "E"},
{"P250", "F"},
{"Tec9", "H"},
{"Cz75a", "I"},
{"MAC10", "K"},
{"Ump45", "L"},
{"Bizon", "M"},
{"MP7", "N"},
{"GalilAR", "Q"},
{"Famas", "R"},
{"M4A1", "S"},
{"Aug", "U"},
{"SG556", "V"},
{"AK47", "W"},
{"G3SG1", "X"},
{"SCAR20", "Y"},
{"AWP", "Z"},
{"SSG08", "a"},
{"XM1014", "b"},
{"Sawedoff", "c"},
{"Mag7", "d"},
{"NOVA", "e"},
{"Negev", "f"},
{"M249", "g"},
{"Taser", "h"},
{"Flashbang", "i"},
{"HEGrenade", "j"},
{"SmokeGrenade", "k"},
{"MolotovGrenade", "l"},
{"DecoyGrenade", "m"},
{"C4", "o"},
{"CBaseAnimGraph", "r"},
{"IncendiaryGrenade", "n"}
};
gunIcons[("P90")] = "P";
gunIcons[("MP9")] = "O";
gunIcons[("Mp5sd")] = "x";
gunIcons[("M4a4")] = "M";
gunIcons[("Knife")] = "]";
gunIcons[("DEagle")] = "A";
gunIcons[("Elite")] = "B";
gunIcons[("FiveSeven")] = "C";
gunIcons[("Glock")] = "D";
gunIcons[("Revolver")] = "J";
gunIcons[("HKP2000")] = "E";
gunIcons[("P250")] = "F";
gunIcons[("Tec9")] = "H";
gunIcons[("Cz75a")] = "I";
gunIcons[("MAC10")] = "K";
gunIcons[("Ump45")] = "L";
gunIcons[("Bizon")] = "M";
gunIcons[("MP7")] = "N";
gunIcons[("GalilAR")] = "Q";
gunIcons[("Famas")] = "R";
gunIcons[("M4A1")] = "S";
gunIcons[("Aug")] = "U";
gunIcons[("SG556")] = "V";
gunIcons[("AK47")] = "W";
gunIcons[("G3SG1")] = "X";
gunIcons[("SCAR20")] = "Y";
gunIcons[("AWP")] = "Z";
gunIcons[("SSG08")] = "a";
gunIcons[("XM1014")] = "b";
gunIcons[("Sawedoff")] = "c";
gunIcons[("Mag7")] = "d";
gunIcons[("NOVA")] = "e";
gunIcons[("Negev")] = "f";
gunIcons[("M249")] = "g";
gunIcons[("Taser")] = "h";
gunIcons[("Flashbang")] = "i";
gunIcons[("HEGrenade")] = "j";
gunIcons[("SmokeGrenade")] = "k";
gunIcons[("MolotovGrenade")] = "l";
gunIcons[("DecoyGrenade")] = "m";
gunIcons[("C4")] = "o";
gunIcons[("CBaseAnimGraph")] = "r";
gunIcons[("IncendiaryGrenade")] = "n";
auto it = gunIcons.find(weapon);
if (it != gunIcons.end())
return it->second;
return "";
}

View File

@@ -0,0 +1,127 @@
#include "Entity.h"
#include "Tracing.h"
#include "Utils/Interfaces.h"
#include "Utils/cVector.h"
#include "iEngineClient.h"
#include "GameResourceService.h"
#include "CheatMenu.h"
extern inline QAngle_t CalculateAngleScalar(const Vector_t& src, const Vector_t& dst);
bool C_CSPlayerPawn::BoneVisible(C_CSPlayerPawn* Local, C_CSPlayerPawn* Enemy, Vector_t Location)
{
Trace_Filter_t Filter = {};
I::Trace->Init(Filter, Local, 0x1C3003, 4, 7);
Game_Trace_t Trace = {};
Ray_t Ray = {};
Vector_t LocalEye = Local->GetEyePosition();
Vector_t EnemyEye = Location;
I::Trace->TraceShape(Ray, &LocalEye, &EnemyEye, Filter, Trace);
return Trace.HitEntity && Trace.HitEntity->GetRefEHandle().GetEntryIndex() == Enemy->GetRefEHandle().GetEntryIndex() || Trace.Fraction > 0.97f;
}
bool C_CSPlayerPawn::EyeVisible(C_CSPlayerPawn* Local, C_CSPlayerPawn* Enemy)
{
Trace_Filter_t Filter = {};
I::Trace->Init(Filter, Local, 0x1C3003, 4, 7);
Game_Trace_t Trace = {};
Ray_t Ray = {};
Vector_t LocalEye = Local->GetEyePosition();
Vector_t EnemyEye = Enemy->GetEyePosition();
I::Trace->TraceShape(Ray, &LocalEye, &EnemyEye, Filter, Trace);
return Trace.HitEntity && Trace.HitEntity->GetRefEHandle().GetEntryIndex() == Enemy->GetRefEHandle().GetEntryIndex() || Trace.Fraction > 0.97f;
}
bool C_CSPlayerPawn::TriggerHit(C_CSPlayerPawn* Local, C_CSPlayerPawn* Enemy, CCSGOInput* pInput, const CBone& BoneData)
{
Trace_Filter_t Filter = {};
I::Trace->Init(Filter, Local, 0x1C3003, 4, 7);
Game_Trace_t Trace = {};
Ray_t Ray = {};
Vector_t Start = Local->GetEyePosition();
QAngle_t AdjustedAngles = pInput->GetViewAngles();
Vector_t Direction = M::AngleToDirection(AdjustedAngles);
Vector_t TargetPosition = Start + (Direction * 8192.0f);
I::Trace->TraceShape(Ray, &Start, &TargetPosition, Filter, Trace);
if (Trace.HitEntity && Trace.HitEntity->GetRefEHandle().GetEntryIndex() == Enemy->GetRefEHandle().GetEntryIndex())
{
Vector_t HitPosition = Trace.m_end_pos;
for (const auto& BonePosition : BoneData.BonePositions)
{
if (!BonePosition.RayTraceVisible)
continue;
float Distance = (HitPosition - BonePosition.Location).Length();
if (Distance < MenuConfig::TriggerbotDistanceThreshold)
{
QAngle_t ViewAngles = pInput->GetViewAngles();
QAngle_t TargetAngles = CalculateAngleScalar(HitPosition, BonePosition.Location);
float AngleDifference = (ViewAngles - TargetAngles).Length();
if (AngleDifference < MenuConfig::TriggerbotAngleTolerance)
return true;
}
}
}
return false;
}
bool C_Chicken::ChickenVisible(C_CSPlayerPawn* Local, C_Chicken* Enemy)
{
Trace_Filter_t Filter = {};
I::Trace->Init(Filter, Local, 0x1C3003, 4, 7);
Game_Trace_t Trace = {};
Ray_t Ray = {};
Vector_t LocalEye = Local->GetEyePosition();
Vector_t EnemyEye = Enemy->GetEyePosition();
I::Trace->TraceShape(Ray, &LocalEye, &EnemyEye, Filter, Trace);
return Trace.HitEntity && Trace.HitEntity->GetRefEHandle().GetEntryIndex() == Enemy->GetRefEHandle().GetEntryIndex() || Trace.Fraction > 0.97f;
}
Vector_t C_CSPlayerPawn::GetEyePosition()
{
Vector_t EyePosition;
M::CallVFunc<void, 166>(this, &EyePosition);
return EyePosition;
}
Vector_t C_Chicken::GetEyePosition()
{
Vector_t EyePosition;
M::CallVFunc<void, 166>(this, &EyePosition);
return EyePosition;
}
CCSPlayerController* CCSPlayerController::GetLocalPlayerController()
{
const int nIndex = I::Engine->GetLocalPlayer();
return I::GameResourceService->pGameEntitySystem->Get<CCSPlayerController>(nIndex);
}
C_BaseEntity* C_BaseEntity::GetLocalPlayer()
{
const int nIndex = I::Engine->GetLocalPlayer();
return I::GameResourceService->pGameEntitySystem->Get(nIndex);
}
bool C_CSPlayerPawn::IsOtherEnemy()
{
if (this->GetTeam() == GetLocalPlayer()->GetTeam())
return false;
return true;
}

View File

@@ -0,0 +1,390 @@
#pragma once
#include "Utils/Memory.h"
#include "Utils/FNV1A.h"
#include "Schema/SchemaSetup.h"
#include "EntityHandle.h"
#include "Utils/cVector.h"
#include "Bones.h"
#include <memory>
#include "chrono"
#include "Colors.h"
class CEntityIdentity;
class CBaseHandle;
class CSkeletonInstance;
class CGameSceneNode;
class C_BaseEntity;
class C_BaseModelEntity;
class C_BasePlayerPawn;
class C_CSPlayerPawnBase;
class C_CSPlayerPawn;
class CBasePlayerController;
class CCSPlayerController;
class CEntityInstance;
class C_CSWeaponBase;
class C_Inferno;
class C_EnvSky;
class C_SmokeGrenadeProjectile;
class CCSGOInput;
inline SchemaClassInfoData_t* pClassInfo;
inline C_EnvSky* g_pEnvSky = nullptr;
inline C_SmokeGrenadeProjectile* g_pSmokeGrenadeProjectile = nullptr;
struct PlayerEntity
{
bool CanHit = false;
struct C_CSPlayerController
{
std::string m_sSanitizedPlayerName;
}Controller;
struct C_CSPlayerPawnBase
{
Vector_t m_vOldOrigin{ 0, 0, 0 };
CBone BoneData;
C_CSWeaponBase* CSWeaponBase = nullptr;
Vector4D_t Rectangle;
bool isVisible = false;
int Health = 0;
}Pawn;
};
struct WeaponEntity
{
C_CSWeaponBase* CSWeaponBase = nullptr;
Vector_t WorldPosition{ 0, 0, 0 };
std::string Name;
bool isWeapon = false;
};
struct ChickenEntity
{
struct CChicken
{
Vector_t WorldPosition{ 0, 0, 0 };
Vector4D_t Rectangle;
CBone BoneData;
bool isVisible = false;
std::string Name;
}Chicken;
};
struct InfernoEntity
{
int UniqueInfernoID;
std::chrono::steady_clock::time_point StartTime;
struct InfernoDetails
{
C_Inferno* Base;
Vector_t WorldPosition{ 0, 0, 0 };
bool isBurning = false;
} Inferno;
};
inline std::unordered_map<int, InfernoEntity> ActiveInfernoEntities;
inline int NextInfernoID = 0;
inline std::vector<PlayerEntity> ActivePlayersA, ActivePlayersB;
inline std::vector<PlayerEntity>* CurrentPlayerList = &ActivePlayersA, * NextPlayerList = &ActivePlayersB;
inline std::unique_ptr<PlayerEntity> cPlayerEntity = std::make_unique<PlayerEntity>();
inline std::vector<WeaponEntity> WeaponListA, WeaponListB;
inline std::vector<WeaponEntity>* CurrentWeaponList = &WeaponListA, * NextWeaponList = &WeaponListB;
inline std::unique_ptr<WeaponEntity> cWeaponEntity = std::make_unique<WeaponEntity>();
inline std::vector<ChickenEntity> ChickenListA, ChickenListB;
inline std::vector<ChickenEntity>* CurrentChickenList = &ChickenListA, * NextChickenList = &ChickenListB;
inline std::unique_ptr<ChickenEntity> CurrentChickenEntity = std::make_unique<ChickenEntity>();
class CEntityIdentity
{
public:
SCHEMA_ADD_OFFSET(std::uint32_t, GetIndex, 0x10);
SCHEMA_ADD_FIELD(const char*, GetDesignerName, "CEntityIdentity->m_designerName");
SCHEMA_ADD_FIELD(std::uint32_t, GetFlags, "CEntityIdentity->m_flags");
bool IsValid()
{
return GetIndex() != INVALID_EHANDLE_INDEX;
}
int GetEntryIndex()
{
if (!IsValid())
return ENT_ENTRY_MASK;
return GetIndex() & ENT_ENTRY_MASK;
}
int GetSerialNumber()
{
return GetIndex() >> NUM_SERIAL_NUM_SHIFT_BITS;
}
CEntityInstance* pInstance;
};
class CEntityInstance
{
public:
void GetSchemaClassInfo(SchemaClassInfoData_t** pReturn)
{
return M::CallVFunc<void, 38U>(this, pReturn);
}
CBaseHandle GetRefEHandle()
{
CEntityIdentity* pIdentity = GetIdentity();
if (pIdentity == nullptr)
return CBaseHandle();
return CBaseHandle(pIdentity->GetEntryIndex(), pIdentity->GetSerialNumber() - (pIdentity->GetFlags() & 1));
}
SCHEMA_ADD_FIELD(CEntityIdentity*, GetIdentity, "CEntityInstance->m_pEntity");
};
class C_BaseEntity : public CEntityInstance
{
public:
static C_BaseEntity* GetLocalPlayer();
bool IsWeapon()
{
static SchemaClassInfoData_t* pWeaponBaseClass = nullptr;
if (pWeaponBaseClass == nullptr)
I::SchemaSystem->FindTypeScopeForModule("client.dll")->FindDeclaredClass(&pWeaponBaseClass, "C_CSWeaponBase");
SchemaClassInfoData_t* pClassInfo;
GetSchemaClassInfo(&pClassInfo);
if (pClassInfo == nullptr)
return false;
return (pClassInfo->InheritsFrom(pWeaponBaseClass));
}
SCHEMA_ADD_FIELD(std::uint8_t, GetTeam, "C_BaseEntity->m_iTeamNum");
SCHEMA_ADD_FIELD(CGameSceneNode*, GetGameSceneNode, "C_BaseEntity->m_pGameSceneNode");
SCHEMA_ADD_FIELD(std::int32_t, GetHealth, "C_BaseEntity->m_iHealth");
};
class C_BaseModelEntity : public C_BaseEntity
{
public:
SCHEMA_ADD_FIELD(Vector_t, GetViewOffset, "C_BaseModelEntity->m_vecViewOffset");
};
class C_BasePlayerPawn : public C_BaseModelEntity
{
public:
SCHEMA_ADD_FIELD(Vector_t, GetOrigin, "C_BasePlayerPawn->m_vOldOrigin");
};
class C_CSPlayerPawnBase : public C_BasePlayerPawn
{
public:
SCHEMA_ADD_FIELD(C_CSWeaponBase*, CSWeaponBase, "C_CSPlayerPawnBase->m_pClippingWeapon");
};
struct CUtlVector
{
int count;
int pad;
QAngle_t* data;
};
class C_CSPlayerPawn : public C_CSPlayerPawnBase
{
public:
Vector_t GetEyePosition();
bool IsOtherEnemy();
bool BoneVisible(C_CSPlayerPawn* Local, C_CSPlayerPawn* Enemy, Vector_t Location);
bool EyeVisible(C_CSPlayerPawn* Local, C_CSPlayerPawn* Enemy);
bool TriggerHit(C_CSPlayerPawn* Local, C_CSPlayerPawn* Enemy, CCSGOInput* pInput, const CBone& BoneData);
SCHEMA_ADD_FIELD(QAngle_t, GetPunchAngle, "C_CSPlayerPawn->m_aimPunchAngle");
SCHEMA_ADD_FIELD(CUtlVector, GetCachedAngle, "C_CSPlayerPawn->m_aimPunchCache");
SCHEMA_ADD_FIELD(int, GetShotsFired, "C_CSPlayerPawn->m_iShotsFired");
};
class CBasePlayerController : public C_BaseModelEntity
{
public:
SCHEMA_ADD_FIELD(CBaseHandle, GetPawnHandle, "CBasePlayerController->m_hPawn");
SCHEMA_ADD_FIELD(bool, IsLocalPlayerController, "CBasePlayerController->m_bIsLocalPlayerController");
SCHEMA_ADD_FIELD(bool, IsPawnAlive, "CCSPlayerController->m_bPawnIsAlive");
};
class CCSPlayerController : public CBasePlayerController
{
public:
SCHEMA_ADD_FIELD(const char*, GetPlayerName, "CCSPlayerController->m_sSanitizedPlayerName");
static CCSPlayerController* GetLocalPlayerController();
SCHEMA_ADD_FIELD(CBaseHandle, GetPlayerPawnHandle, "CCSPlayerController->m_hPlayerPawn");
};
class CBaseAnimGraph : public C_BaseModelEntity
{
public:
};
class C_BaseFlex : public CBaseAnimGraph
{
public:
};
class C_EconEntity : public C_BaseFlex
{
public:
};
class C_BasePlayerWeapon : public C_EconEntity
{
public:
};
class C_CSWeaponBase : public C_BasePlayerWeapon
{
public:
SCHEMA_ADD_FIELD(int, m_nNextPrimaryAttackTick, "C_BasePlayerWeapon->m_nNextPrimaryAttackTick");
};
class CGameSceneNode
{
public:
SCHEMA_ADD_FIELD(CEntityInstance*, GetOwner, "CGameSceneNode->m_pOwner");
SCHEMA_ADD_FIELD(Vector_t, GetAbsOrigin, "CGameSceneNode->m_vecAbsOrigin");
SCHEMA_ADD_FIELD(Vector_t, GetRenderOrigin, "CGameSceneNode->m_vRenderOrigin");
SCHEMA_ADD_FIELD(QAngle_t, GetAngleRotation, "CGameSceneNode->m_angRotation");
SCHEMA_ADD_FIELD(QAngle_t, GetAbsAngleRotation, "CGameSceneNode->m_angAbsRotation");
SCHEMA_ADD_FIELD(bool, IsDormant, "CGameSceneNode->m_bDormant");
SCHEMA_ADD_FIELD(Vector_t, GetOrigin, "CGameSceneNode->m_vecOrigin");
CSkeletonInstance* GetSkeletonInstance()
{
return M::CallVFunc<CSkeletonInstance*, 8U>(this);
}
};
class CSkeletonInstance : public CGameSceneNode
{
public:
};
class C_Chicken : public C_BaseEntity
{
public:
Vector_t GetEyePosition();
bool ChickenVisible(C_CSPlayerPawn* Local, C_Chicken* Enemy);
};
class C_Inferno : public C_BaseEntity
{
public:
SCHEMA_ADD_FIELD(bool, IsBurning, "C_Inferno->m_bFireIsBurning");
SCHEMA_ADD_FIELD(Vector_t, GetMinBounds, "C_Inferno->m_minBounds");
SCHEMA_ADD_FIELD(Vector_t, GetMaxBounds, "C_Inferno->m_maxBounds");
SCHEMA_ADD_FIELD(Vector_t, GetFirePositions, "C_Inferno->m_firePositions");
};
class cAggregateSceneObject
{
public:
unsigned char Padding[0xE4];
float R;
float G;
float B;
};
class C_EnvSky
{
public:
SCHEMA_ADD_FIELD(bool, m_bStartDisabled, "C_EnvSky->m_bStartDisabled");
SCHEMA_ADD_FIELD(Color_t, m_vTintColor, "C_EnvSky->m_vTintColor");
SCHEMA_ADD_FIELD(Color_t, m_vTintColorLightingOnly, "C_EnvSky->m_vTintColorLightingOnly");
SCHEMA_ADD_FIELD(float, m_flBrightnessScale, "C_EnvSky->m_flBrightnessScale");
SCHEMA_ADD_FIELD(int, m_nFogType, "C_EnvSky->m_nFogType");
SCHEMA_ADD_FIELD(float, m_flFogMinStart, "C_EnvSky->m_flFogMinStart");
SCHEMA_ADD_FIELD(float, m_flFogMinEnd, "C_EnvSky->m_flFogMinEnd");
SCHEMA_ADD_FIELD(float, m_flFogMaxStart, "C_EnvSky->m_flFogMaxStart");
SCHEMA_ADD_FIELD(float, m_flFogMaxEnd, "C_EnvSky->m_flFogMaxEnd");
SCHEMA_ADD_FIELD(bool, m_bEnabled, "C_EnvSky->m_bEnabled");
};
class C_SmokeGrenadeProjectile
{
public:
SCHEMA_ADD_FIELD(Vector_t, m_vSmokeColor, "C_SmokeGrenadeProjectile->m_vSmokeColor");
};
class C_HitBox
{
public:
const char* m_name; // 0x0
const char* m_sSurfaceProperty; // 0x8
const char* m_sBoneName; // 0x10
Vector_t m_vMinBounds; // 0x18
Vector_t m_vMaxBounds; // 0x24
float m_flShapeRadius; // 0x30
uint32_t m_nBoneNameHash; // 0x34
int32_t m_nGroupId; // 0x38
uint8_t m_nShapeType; // 0x3c
bool m_bTranslationOnly; // 0x3d
private:
uint8_t __pad003e[0x2]; // 0x3e
public:
uint32_t m_CRC; // 0x40
Color_t m_cRenderColor; // 0x44
uint16_t m_nHitBoxIndex; // 0x48
char pad2[0x26];
};

View File

@@ -0,0 +1,52 @@
#pragma once
#include "cstdint"
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF
#define ENT_ENTRY_MASK 0x7FFF
#define NUM_SERIAL_NUM_SHIFT_BITS 15
#define ENT_MAX_NETWORKED_ENTRY 16384
class CBaseHandle
{
public:
CBaseHandle() noexcept :
nIndex(INVALID_EHANDLE_INDEX) { }
CBaseHandle(const int nEntry, const int nSerial) noexcept
{
nIndex = nEntry | (nSerial << NUM_SERIAL_NUM_SHIFT_BITS);
}
bool operator!=(const CBaseHandle& other) const noexcept
{
return nIndex != other.nIndex;
}
bool operator==(const CBaseHandle& other) const noexcept
{
return nIndex == other.nIndex;
}
bool operator<(const CBaseHandle& other) const noexcept
{
return nIndex < other.nIndex;
}
[[nodiscard]] bool IsValid() const noexcept
{
return nIndex != INVALID_EHANDLE_INDEX;
}
[[nodiscard]] int GetEntryIndex() const noexcept
{
return static_cast<int>(nIndex & ENT_ENTRY_MASK);
}
[[nodiscard]] int GetSerialNumber() const noexcept
{
return static_cast<int>(nIndex >> NUM_SERIAL_NUM_SHIFT_BITS);
}
private:
std::uint32_t nIndex;
};

View File

@@ -0,0 +1,12 @@
#pragma once
#include "Utils/Defines.h"
class CGameEntitySystem;
class IGameResourceService
{
public:
MEM_PAD(0x58);
CGameEntitySystem* pGameEntitySystem;
};

View File

@@ -0,0 +1,303 @@
#include "Hooks.h"
#include "W2S.h"
#include "CRC.h"
extern Vector4D_t Get2DBox(Vector_t WorldPosition, const float Height);
extern VOID Recoil(CCSGOInput* Input);
extern VOID TriggerBot(CCSGOInput* pInput);
static const std::unordered_map<std::string, size_t> ClassTrimMap =
{
{"C_Knife", 2},
{"C_Weapon", 8},
{"C_DEagle", 2},
{"C_Flashbang", 2},
{"C_SmokeGrenade", 2},
{"C_HEGrenade", 2},
{"C_IncendiaryGrenade", 2},
{"C_DecoyGrenade", 2},
{"C_WeaponSCAR20", 8},
{"C_C4", 2},
{"C_AK47", 2},
{"C_MolotovGrenade", 2},
{"C_PlantedC4", 9},
{"CBaseAnimGraph", 0}
};
inline void PlayerEntities(C_BaseEntity* pEntity, SchemaClassInfoData_t* pClassInfo, CCSGOInput* pInput)
{
if (FNV1A::Hash(pClassInfo->szName) != FNV1A::HashConst("CCSPlayerController"))
return;
CCSPlayerController* Controller = reinterpret_cast<CCSPlayerController*>(pEntity);
if (Controller == nullptr || Controller->IsLocalPlayerController())
return;
C_CSPlayerPawn* Pawn = I::GameResourceService->pGameEntitySystem->Get<C_CSPlayerPawn>(Controller->GetPawnHandle());
if (Pawn == nullptr)
return;
if (Pawn->GetHealth() == 0 && !Controller->IsPawnAlive())
return;
if (!Pawn->IsOtherEnemy())
return;
CGameSceneNode* GameSceneNode = Pawn->GetGameSceneNode();
if (GameSceneNode == nullptr)
return;
CSkeletonInstance* Skeleton = GameSceneNode->GetSkeletonInstance();
if (Skeleton == nullptr)
return;
C_CSWeaponBase* CSWeaponBase = Pawn->CSWeaponBase();
if (CSWeaponBase == nullptr)
return;
CBoneData Bones;
PlayerEntity Entity;
Entity.Controller.m_sSanitizedPlayerName = Controller->GetPlayerName();
Entity.Pawn.Health = Pawn->GetHealth();
Entity.Pawn.m_vOldOrigin = Pawn->GetOrigin();
Entity.Pawn.isVisible = Pawn->EyeVisible(SDK::LocalPawn, Pawn);
Entity.Pawn.CSWeaponBase = CSWeaponBase;
Entity.Pawn.Rectangle = Get2DBox(Entity.Pawn.m_vOldOrigin, 75.0f);
Entity.Pawn.BoneData.BonePositions.clear();
Entity.Pawn.BoneData.BonePositions.resize(104);
for (const auto& BoneList : BoneJointList::List)
{
for (const auto& BoneIndex : BoneList)
{
if (BoneIndex >= Entity.Pawn.BoneData.BonePositions.size())
continue;
GetBone(Skeleton, Bones, BoneIndex);
BonePosition Position;
Position.Location = Bones.Location;
Position.WorldVisible = View.WorldToScreen(Bones.Location, Position.ScreenPosition);
Position.RayTraceVisible = Pawn->BoneVisible(SDK::LocalPawn, Pawn, Position.Location);
Entity.Pawn.BoneData.BonePositions[BoneIndex] = Position;
}
}
Entity.CanHit = Pawn->TriggerHit(SDK::LocalPawn, Pawn, pInput, Entity.Pawn.BoneData);
NextPlayerList->push_back(Entity);
}
inline VOID WeaponEntities(C_BaseEntity* pEntity, SchemaClassInfoData_t* pClassInfo)
{
std::string ClassName = pClassInfo->szName;
for (const auto& [key, trimLength] : ClassTrimMap)
{
if (ClassName.find(key) != std::string::npos)
{
ClassName = ClassName.substr(trimLength);
cWeaponEntity->Name = ClassName;
C_CSWeaponBase* CSWeaponBase = reinterpret_cast<C_CSWeaponBase*>(pEntity);
if (CSWeaponBase == nullptr)
return;
CGameSceneNode* GameSceneNode = CSWeaponBase->GetGameSceneNode();
if (GameSceneNode == nullptr)
return;
cWeaponEntity->isWeapon = CSWeaponBase->IsWeapon();
cWeaponEntity->WorldPosition = GameSceneNode->GetOrigin();
cWeaponEntity->CSWeaponBase = CSWeaponBase;
NextWeaponList->push_back(*cWeaponEntity);
}
}
}
inline VOID ChickenEntities(C_BaseEntity* pEntity, SchemaClassInfoData_t* pClassInfo)
{
if (FNV1A::Hash(pClassInfo->szName) != FNV1A::HashConst("C_Chicken"))
return;
C_Chicken* CChicken = reinterpret_cast<C_Chicken*>(pEntity);
if (CChicken == nullptr)
return;
CGameSceneNode* GameSceneNode = CChicken->GetGameSceneNode();
if (GameSceneNode == nullptr)
return;
CurrentChickenEntity->Chicken.Name = "Chicken";
CurrentChickenEntity->Chicken.WorldPosition = GameSceneNode->GetOrigin();
CurrentChickenEntity->Chicken.isVisible = CChicken->ChickenVisible(SDK::LocalPawn, CChicken);
CurrentChickenEntity->Chicken.Rectangle = Get2DBox(CurrentChickenEntity->Chicken.WorldPosition, 25.0f);
NextChickenList->push_back(*CurrentChickenEntity);
}
inline VOID InfernoEntities(C_BaseEntity* pEntity, SchemaClassInfoData_t* pClassInfo)
{
if (FNV1A::Hash(pClassInfo->szName) != FNV1A::HashConst("C_Inferno"))
return;
C_Inferno* Molotov = reinterpret_cast<C_Inferno*>(pEntity);
if (Molotov == nullptr)
return;
int EntityID = reinterpret_cast<int>(pEntity);
if (Molotov->IsBurning())
{
auto& Entity = ActiveInfernoEntities[EntityID];
Entity.Inferno.WorldPosition = Molotov->GetFirePositions();
Entity.Inferno.Base = Molotov;
if (Entity.StartTime == std::chrono::steady_clock::time_point())
{
Entity.StartTime = std::chrono::steady_clock::now();
Entity.UniqueInfernoID = NextInfernoID++;
}
}
else
{
ActiveInfernoEntities.erase(EntityID);
return;
}
}
VOID SkyBox(C_EnvSky* eSky)
{
if (MenuConfig::LightChanger == false || eSky == nullptr)
return;
eSky->m_vTintColorLightingOnly() = Color_t(
MenuConfig::g_SkyboxColor.x * 255.f,
MenuConfig::g_SkyboxColor.y * 255.f,
MenuConfig::g_SkyboxColor.z * 255.f,
MenuConfig::g_SkyboxColor.w * 255.f
);
eSky->m_vTintColor() = Color_t(
MenuConfig::g_SkyboxColor.x * 255.f,
MenuConfig::g_SkyboxColor.y * 255.f,
MenuConfig::g_SkyboxColor.z * 255.f,
MenuConfig::g_SkyboxColor.w * 255.f
);
OriginalUpdateSkybox(eSky);
}
VOID SmokeColor(C_SmokeGrenadeProjectile* Smoke)
{
if (MenuConfig::EnableSmokeColor && Smoke != nullptr)
Smoke->m_vSmokeColor() = MenuConfig::SmokeColorPicker;
}
bool __fastcall hkCreateMove(CCSGOInput* pInput, int nSlot, bool bActive)
{
NextPlayerList->clear(), NextWeaponList->clear(), NextChickenList->clear();
const bool bResult = FakeReturnAddress(Offsets->GameData.ReturnAddress, CreateMove, pInput, nSlot, bActive);
if (!I::Engine->IsConnected() || !I::Engine->IsInGame())
return bResult;
SDK::LocalController = CCSPlayerController::GetLocalPlayerController();
if (SDK::LocalController == nullptr)
return bResult;
SDK::LocalPawn = I::GameResourceService->pGameEntitySystem->Get<C_CSPlayerPawn>(SDK::LocalController->GetPawnHandle());
if (SDK::LocalPawn == nullptr)
return bResult;
CUserCmd* pCmd = pInput->GetUserCmd();
if (pCmd == nullptr)
return bResult;
SDK::Cmd = pCmd;
CBaseUserCmdPB* pBaseCmd = pCmd->csgoUserCmd.pBaseCmd;
if (pBaseCmd == nullptr)
return bResult;
for (int nIndex = 1; nIndex <= I::GameResourceService->pGameEntitySystem->GetHighestEntityIndex(); nIndex++)
{
C_BaseEntity* pEntity = I::GameResourceService->pGameEntitySystem->Get(nIndex);
if (pEntity == nullptr)
continue;
pEntity->GetSchemaClassInfo(&pClassInfo);
if (pClassInfo == nullptr)
continue;
PlayerEntities(pEntity, pClassInfo, pInput);
WeaponEntities(pEntity, pClassInfo);
ChickenEntities(pEntity, pClassInfo);
InfernoEntities(pEntity, pClassInfo);
if (FNV1A::Hash(pClassInfo->szName) == FNV1A::HashConst("C_EnvSky"))
g_pEnvSky = reinterpret_cast<C_EnvSky*>(pEntity);
if (FNV1A::Hash(pClassInfo->szName) == FNV1A::HashConst("C_SmokeGrenadeProjectile"))
g_pSmokeGrenadeProjectile = reinterpret_cast<C_SmokeGrenadeProjectile*>(pEntity);
}
std::swap(CurrentPlayerList, NextPlayerList), std::swap(CurrentWeaponList, NextWeaponList), std::swap(CurrentChickenList, NextChickenList);
SkyBox(g_pEnvSky);
SmokeColor(g_pSmokeGrenadeProjectile);
if (SDK::LocalPawn->GetHealth() > 0 && SDK::LocalController->IsPawnAlive())
{
SilentAim(pCmd);
Aimbot(pInput);
Recoil(pInput);
TriggerBot(pInput);
}
CRC::Save(SDK::Cmd->csgoUserCmd.pBaseCmd);
if (CRC::CalculateCRC(SDK::Cmd->csgoUserCmd.pBaseCmd) == true)
CRC::Apply(SDK::Cmd);
return bResult;
}
void __fastcall hkLightingModulation(__int64 a1, cAggregateSceneObject* SceneObject, __int64 a3)
{
SceneObject->R = MenuConfig::wModulation.LightingColor.x * MenuConfig::wModulation.LightingIntensity;
SceneObject->G = MenuConfig::wModulation.LightingColor.y * MenuConfig::wModulation.LightingIntensity;
SceneObject->B = MenuConfig::wModulation.LightingColor.z * MenuConfig::wModulation.LightingIntensity;
return oLightingModulation(a1, SceneObject, a3);
}

View File

@@ -0,0 +1,44 @@
#pragma once
#include "Entity.h"
#include "Bones.h"
#include "CCSGOInput.h"
#include "Utils/ReturnAddressr.h"
#include "Offsets.h"
#include "iEngineClient.h"
#include "GameResourceService.h"
#include "Utils/Interfaces.h"
#include "cGameEntitySystem.h"
#include "Aimbot.h"
#include "detour.h"
extern bool __fastcall hkCreateMove(CCSGOInput* pInput, int nSlot, bool bActive);
extern void __fastcall hkLightingModulation(__int64 a1, cAggregateSceneObject* SceneObject, __int64 a3);
namespace Hooks
{
inline VOID VirtualTable()
{
uintptr_t dwCSGOInput = Offsets->VTable.dwCSGOInput;
uintptr_t CSGOInput = *reinterpret_cast<uintptr_t*>(dwCSGOInput);
void** CSGOInputVT = reinterpret_cast<void**>(CSGOInput);
void** NewInputVT = M::CopyVirtualTable(CSGOInputVT);
void** NewInputClass = M::CopyVirtualTable(reinterpret_cast<void**>(CSGOInput));
CreateMove = (CreateMove_t)NewInputVT[5];
NewInputClass[5] = (CreateMove_t)hkCreateMove;
*reinterpret_cast<void**>(dwCSGOInput) = NewInputClass;
*reinterpret_cast<void**>(NewInputClass) = NewInputVT;
}
inline VOID Detours()
{
oLightingModulation = (LightingModulationHook_t)Offsets->GameData.WorldModulation;
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)oLightingModulation, hkLightingModulation);
DetourTransactionCommit();
}
}

View File

@@ -0,0 +1,99 @@
//-----------------------------------------------------------------------------
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
//-----------------------------------------------------------------------------
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
// 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.
//-----------------------------------------------------------------------------
#pragma once
//---- Define assertion handler. Defaults to calling assert().
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
// 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.
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
// It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
//#define IMGUI_DISABLE_DEMO_WINDOWS
//#define IMGUI_DISABLE_METRICS_WINDOW
//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
//#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).
//#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)
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite 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.
//#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().
//---- Include imgui_user.h at the end of imgui.h as a convenience
//#define IMGUI_INCLUDE_IMGUI_USER_H
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
//#define IMGUI_USE_BGRA_PACKED_COLOR
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
/*
#define IM_VEC2_CLASS_EXTRA \
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
operator MyVec2() const { return MyVec2(x,y); }
#define IM_VEC4_CLASS_EXTRA \
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
//#define ImDrawIdx unsigned int
//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
//struct ImDrawList;
//struct ImDrawCmd;
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
//#define ImDrawCallback MyImDrawCallback
//---- Debug Tools: Macro to break in Debugger
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
//#define IM_DEBUG_BREAK IM_ASSERT(0)
//#define IM_DEBUG_BREAK __debugbreak()
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
// This adds a small runtime cost which is why it is not enabled by default.
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
//---- Debug Tools: Enable slower asserts
//#define IMGUI_DEBUG_PARANOID
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
/*
namespace ImGui
{
void MyFunction(const char* name, const MyMatrix44& v);
}
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,544 @@
// dear imgui: Renderer for DirectX11
// This needs to be used along with a Platform Binding (e.g. Win32)
// Implemented features:
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp
// https://github.com/ocornut/imgui
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore.
// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
// 2018-08-01: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility.
// 2018-07-13: DirectX11: Fixed unreleased resources in Init and Shutdown functions.
// 2018-06-08: Misc: Extracted imgui_impl_dx11.cpp/.h away from the old combined DX11+Win32 example.
// 2018-06-08: DirectX11: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2016-05-07: DirectX11: Disabling depth-write.
#include "imgui.h"
#include "imgui_impl_dx11.h"
// DirectX
#include <stdio.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#ifdef _MSC_VER
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
#endif
// DirectX data
static ID3D11Device* g_pd3dDevice = NULL;
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
static IDXGIFactory* g_pFactory = NULL;
static ID3D11Buffer* g_pVB = NULL;
static ID3D11Buffer* g_pIB = NULL;
static ID3D10Blob* g_pVertexShaderBlob = NULL;
static ID3D11VertexShader* g_pVertexShader = NULL;
static ID3D11InputLayout* g_pInputLayout = NULL;
static ID3D11Buffer* g_pVertexConstantBuffer = NULL;
static ID3D10Blob* g_pPixelShaderBlob = NULL;
static ID3D11PixelShader* g_pPixelShader = NULL;
static ID3D11SamplerState* g_pFontSampler = NULL;
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
static ID3D11RasterizerState* g_pRasterizerState = NULL;
static ID3D11BlendState* g_pBlendState = NULL;
static ID3D11DepthStencilState* g_pDepthStencilState = NULL;
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
struct VERTEX_CONSTANT_BUFFER
{
float mvp[4][4];
};
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
{
// Setup viewport
D3D11_VIEWPORT vp;
memset(&vp, 0, sizeof(D3D11_VIEWPORT));
vp.Width = draw_data->DisplaySize.x;
vp.Height = draw_data->DisplaySize.y;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = vp.TopLeftY = 0;
ctx->RSSetViewports(1, &vp);
// Setup shader and vertex buffers
unsigned int stride = sizeof(ImDrawVert);
unsigned int offset = 0;
ctx->IASetInputLayout(g_pInputLayout);
ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ctx->VSSetShader(g_pVertexShader, NULL, 0);
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
ctx->PSSetShader(g_pPixelShader, NULL, 0);
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
ctx->GSSetShader(NULL, NULL, 0);
ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
ctx->CSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
// Setup blend state
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
ctx->RSSetState(g_pRasterizerState);
}
// Render function
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
{
// Avoid rendering when minimized
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
return;
ID3D11DeviceContext* ctx = g_pd3dDeviceContext;
// Create and grow vertex/index buffers if needed
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
{
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.ByteWidth = g_VertexBufferSize * sizeof(ImDrawVert);
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVB) < 0)
return;
}
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
{
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.ByteWidth = g_IndexBufferSize * sizeof(ImDrawIdx);
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pIB) < 0)
return;
}
// Upload vertex/index data into a single contiguous GPU buffer
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
if (ctx->Map(g_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
return;
if (ctx->Map(g_pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK)
return;
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
vtx_dst += cmd_list->VtxBuffer.Size;
idx_dst += cmd_list->IdxBuffer.Size;
}
ctx->Unmap(g_pVB, 0);
ctx->Unmap(g_pIB, 0);
// Setup orthographic projection matrix into our constant buffer
// 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.
{
D3D11_MAPPED_SUBRESOURCE mapped_resource;
if (ctx->Map(g_pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
return;
VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource.pData;
float L = draw_data->DisplayPos.x;
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
float T = draw_data->DisplayPos.y;
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
float mvp[4][4] =
{
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.5f, 0.0f },
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
};
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
ctx->Unmap(g_pVertexConstantBuffer, 0);
}
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
struct BACKUP_DX11_STATE
{
UINT ScissorRectsCount, ViewportsCount;
D3D11_RECT ScissorRects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
D3D11_VIEWPORT Viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
ID3D11RasterizerState* RS;
ID3D11BlendState* BlendState;
FLOAT BlendFactor[4];
UINT SampleMask;
UINT StencilRef;
ID3D11DepthStencilState* DepthStencilState;
ID3D11ShaderResourceView* PSShaderResource;
ID3D11SamplerState* PSSampler;
ID3D11PixelShader* PS;
ID3D11VertexShader* VS;
ID3D11GeometryShader* GS;
UINT PSInstancesCount, VSInstancesCount, GSInstancesCount;
ID3D11ClassInstance *PSInstances[256], *VSInstances[256], *GSInstances[256]; // 256 is max according to PSSetShader documentation
D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology;
ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
DXGI_FORMAT IndexBufferFormat;
ID3D11InputLayout* InputLayout;
};
BACKUP_DX11_STATE old;
old.ScissorRectsCount = old.ViewportsCount = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects);
ctx->RSGetViewports(&old.ViewportsCount, old.Viewports);
ctx->RSGetState(&old.RS);
ctx->OMGetBlendState(&old.BlendState, old.BlendFactor, &old.SampleMask);
ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
ctx->PSGetShaderResources(0, 1, &old.PSShaderResource);
ctx->PSGetSamplers(0, 1, &old.PSSampler);
old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256;
ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
ctx->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount);
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
ctx->IAGetInputLayout(&old.InputLayout);
// Setup desired DX state
ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
// Render command lists
// (Because we merged all buffers into a single one, we maintain our own offset into them)
int global_idx_offset = 0;
int global_vtx_offset = 0;
ImVec2 clip_off = draw_data->DisplayPos;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback != NULL)
{
// User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
else
pcmd->UserCallback(cmd_list, pcmd);
}
else
{
// Apply scissor/clipping rectangle
const D3D11_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) };
ctx->RSSetScissorRects(1, &r);
// Bind texture, Draw
ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->TextureId;
ctx->PSSetShaderResources(0, 1, &texture_srv);
ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset);
}
}
global_idx_offset += cmd_list->IdxBuffer.Size;
global_vtx_offset += cmd_list->VtxBuffer.Size;
}
// Restore modified DX state
ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
ctx->RSSetState(old.RS); if (old.RS) old.RS->Release();
ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release();
ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release();
ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release();
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
ctx->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount); if (old.PS) old.PS->Release();
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
ctx->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release();
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release();
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
}
static void ImGui_ImplDX11_CreateFontsTexture()
{
// Build texture atlas
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// Upload texture to graphics system
{
D3D11_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Width = width;
desc.Height = height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
ID3D11Texture2D *pTexture = NULL;
D3D11_SUBRESOURCE_DATA subResource;
subResource.pSysMem = pixels;
subResource.SysMemPitch = desc.Width * 4;
subResource.SysMemSlicePitch = 0;
g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
// Create texture view
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
ZeroMemory(&srvDesc, sizeof(srvDesc));
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = desc.MipLevels;
srvDesc.Texture2D.MostDetailedMip = 0;
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
pTexture->Release();
}
// Store our identifier
io.Fonts->TexID = (ImTextureID)g_pFontTextureView;
// Create texture sampler
{
D3D11_SAMPLER_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
desc.MipLODBias = 0.f;
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
desc.MinLOD = 0.f;
desc.MaxLOD = 0.f;
g_pd3dDevice->CreateSamplerState(&desc, &g_pFontSampler);
}
}
bool ImGui_ImplDX11_CreateDeviceObjects()
{
if (!g_pd3dDevice)
return false;
if (g_pFontSampler)
ImGui_ImplDX11_InvalidateDeviceObjects();
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
// If you would like to use this DX11 sample code but remove this dependency you can:
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
// Create the vertex shader
{
static const char* vertexShader =
"cbuffer vertexBuffer : register(b0) \
{\
float4x4 ProjectionMatrix; \
};\
struct VS_INPUT\
{\
float2 pos : POSITION;\
float4 col : COLOR0;\
float2 uv : TEXCOORD0;\
};\
\
struct PS_INPUT\
{\
float4 pos : SV_POSITION;\
float4 col : COLOR0;\
float2 uv : TEXCOORD0;\
};\
\
PS_INPUT main(VS_INPUT input)\
{\
PS_INPUT output;\
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
output.col = input.col;\
output.uv = input.uv;\
return output;\
}";
D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &g_pVertexShaderBlob, NULL);
if (g_pVertexShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
return false;
if (g_pd3dDevice->CreateVertexShader((DWORD*)g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
return false;
// Create the input layout
D3D11_INPUT_ELEMENT_DESC local_layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, g_pVertexShaderBlob->GetBufferPointer(), g_pVertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
return false;
// Create the constant buffer
{
D3D11_BUFFER_DESC desc;
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVertexConstantBuffer);
}
}
// Create the pixel shader
{
static const char* pixelShader =
"struct PS_INPUT\
{\
float4 pos : SV_POSITION;\
float4 col : COLOR0;\
float2 uv : TEXCOORD0;\
};\
sampler sampler0;\
Texture2D texture0;\
\
float4 main(PS_INPUT input) : SV_Target\
{\
float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \
return out_col; \
}";
D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &g_pPixelShaderBlob, NULL);
if (g_pPixelShaderBlob == NULL) // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
return false;
if (g_pd3dDevice->CreatePixelShader((DWORD*)g_pPixelShaderBlob->GetBufferPointer(), g_pPixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)
return false;
}
// Create the blending setup
{
D3D11_BLEND_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.AlphaToCoverageEnable = false;
desc.RenderTarget[0].BlendEnable = true;
desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
g_pd3dDevice->CreateBlendState(&desc, &g_pBlendState);
}
// Create the rasterizer state
{
D3D11_RASTERIZER_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.FillMode = D3D11_FILL_SOLID;
desc.CullMode = D3D11_CULL_NONE;
desc.ScissorEnable = true;
desc.DepthClipEnable = true;
g_pd3dDevice->CreateRasterizerState(&desc, &g_pRasterizerState);
}
// Create depth-stencil State
{
D3D11_DEPTH_STENCIL_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.DepthEnable = false;
desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
desc.StencilEnable = false;
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
desc.BackFace = desc.FrontFace;
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
}
ImGui_ImplDX11_CreateFontsTexture();
return true;
}
void ImGui_ImplDX11_InvalidateDeviceObjects()
{
if (!g_pd3dDevice)
return;
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
if (g_pBlendState) { g_pBlendState->Release(); g_pBlendState = NULL; }
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
if (g_pPixelShaderBlob) { g_pPixelShaderBlob->Release(); g_pPixelShaderBlob = NULL; }
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
if (g_pVertexShaderBlob) { g_pVertexShaderBlob->Release(); g_pVertexShaderBlob = NULL; }
}
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
{
// Setup back-end capabilities flags
ImGuiIO& io = ImGui::GetIO();
io.BackendRendererName = "imgui_impl_dx11";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
// Get factory from device
IDXGIDevice* pDXGIDevice = NULL;
IDXGIAdapter* pDXGIAdapter = NULL;
IDXGIFactory* pFactory = NULL;
if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK)
if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
{
g_pd3dDevice = device;
g_pd3dDeviceContext = device_context;
g_pFactory = pFactory;
}
if (pDXGIDevice) pDXGIDevice->Release();
if (pDXGIAdapter) pDXGIAdapter->Release();
g_pd3dDevice->AddRef();
g_pd3dDeviceContext->AddRef();
return true;
}
void ImGui_ImplDX11_Shutdown()
{
ImGui_ImplDX11_InvalidateDeviceObjects();
if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
}
void ImGui_ImplDX11_NewFrame()
{
if (!g_pFontSampler)
ImGui_ImplDX11_CreateDeviceObjects();
}

View File

@@ -0,0 +1,24 @@
// dear imgui: Renderer for DirectX11
// This needs to be used along with a Platform Binding (e.g. Win32)
// Implemented features:
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
// https://github.com/ocornut/imgui
#pragma once
struct ID3D11Device;
struct ID3D11DeviceContext;
IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing ImGui state.
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();

View File

@@ -0,0 +1,323 @@
// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications)
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
// Implemented features:
// [X] Platform: Clipboard support (for Win32 this is actually part of core imgui)
// [X] Platform:
//
// shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
#include "imgui.h"
#include "imgui_impl_win32.h"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <XInput.h>
#include <tchar.h>
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent.
// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages.
// 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
// 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads).
// 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples.
// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag.
// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
// 2018-02-06: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert.
// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag.
// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read.
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
// Win32 Data
static HWND g_hWnd = 0;
static INT64 g_Time = 0;
static INT64 g_TicksPerSecond = 0;
static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT;
static bool g_HasGamepad = false;
static bool g_WantUpdateHasGamepad = true;
// Functions
bool ImGui_ImplWin32_Init(void* hwnd)
{
if (!::QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
return false;
if (!::QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
return false;
// Setup back-end capabilities flags
g_hWnd = (HWND)hwnd;
ImGuiIO& io = ImGui::GetIO();
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
io.BackendPlatformName = "imgui_impl_win32";
io.ImeWindowHandle = hwnd;
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
io.KeyMap[ImGuiKey_Tab] = VK_TAB;
io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
io.KeyMap[ImGuiKey_Home] = VK_HOME;
io.KeyMap[ImGuiKey_End] = VK_END;
io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN;
io.KeyMap[ImGuiKey_A] = 'A';
io.KeyMap[ImGuiKey_C] = 'C';
io.KeyMap[ImGuiKey_V] = 'V';
io.KeyMap[ImGuiKey_X] = 'X';
io.KeyMap[ImGuiKey_Y] = 'Y';
io.KeyMap[ImGuiKey_Z] = 'Z';
return true;
}
void ImGui_ImplWin32_Shutdown()
{
g_hWnd = (HWND)0;
}
static bool ImGui_ImplWin32_UpdateMouseCursor()
{
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
return false;
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
{
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
::SetCursor(NULL);
}
else
{
// Show OS mouse cursor
LPTSTR win32_cursor = IDC_ARROW;
switch (imgui_cursor)
{
case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
}
::SetCursor(::LoadCursor(NULL, win32_cursor));
}
return true;
}
static void ImGui_ImplWin32_UpdateMousePos()
{
ImGuiIO& io = ImGui::GetIO();
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
if (io.WantSetMousePos)
{
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
::ClientToScreen(g_hWnd, &pos);
::SetCursorPos(pos.x, pos.y);
}
// Set mouse position
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
POINT pos;
if (HWND active_window = ::GetForegroundWindow())
if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd))
if (::GetCursorPos(&pos) && ::ScreenToClient(g_hWnd, &pos))
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
}
#ifdef _MSC_VER
#pragma comment(lib, "xinput")
#endif
// Gamepad navigation mapping
static void ImGui_ImplWin32_UpdateGamepads()
{
ImGuiIO& io = ImGui::GetIO();
memset(io.NavInputs, 0, sizeof(io.NavInputs));
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
return;
// Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
if (g_WantUpdateHasGamepad)
{
XINPUT_CAPABILITIES caps;
g_HasGamepad = (XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS);
g_WantUpdateHasGamepad = false;
}
XINPUT_STATE xinput_state;
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
if (g_HasGamepad && XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
{
const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
#define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; }
#define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A
MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B
MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X
MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y
MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left
MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right
MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up
MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down
MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767);
#undef MAP_BUTTON
#undef MAP_ANALOG
}
}
void ImGui_ImplWin32_NewFrame()
{
ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
// Setup display size (every frame to accommodate for window resizing)
RECT rect;
::GetClientRect(g_hWnd, &rect);
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
// Setup time step
INT64 current_time;
::QueryPerformanceCounter((LARGE_INTEGER*)&current_time);
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
g_Time = current_time;
// Read keyboard modifiers inputs
io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
io.KeySuper = false;
// io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below.
// Update OS mouse position
ImGui_ImplWin32_UpdateMousePos();
// Update OS mouse cursor with the cursor requested by imgui
ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
if (g_LastMouseCursor != mouse_cursor)
{
g_LastMouseCursor = mouse_cursor;
ImGui_ImplWin32_UpdateMouseCursor();
}
// Update game controllers (if enabled and available)
// ImGui_ImplWin32_UpdateGamepads();
}
// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif
#ifndef DBT_DEVNODES_CHANGED
#define DBT_DEVNODES_CHANGED 0x0007
#endif
// Process Win32 mouse/keyboard inputs.
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds.
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (ImGui::GetCurrentContext() == NULL)
return 0;
ImGuiIO& io = ImGui::GetIO();
switch (msg)
{
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK:
{
int button = 0;
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; }
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
::SetCapture(hwnd);
io.MouseDown[button] = true;
return 0;
}
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_XBUTTONUP:
{
int button = 0;
if (msg == WM_LBUTTONUP) { button = 0; }
if (msg == WM_RBUTTONUP) { button = 1; }
if (msg == WM_MBUTTONUP) { button = 2; }
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
io.MouseDown[button] = false;
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
::ReleaseCapture();
return 0;
}
case WM_MOUSEWHEEL:
io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
return 0;
case WM_MOUSEHWHEEL:
io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
return 0;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (wParam < 256)
io.KeysDown[wParam] = 1;
return 0;
case WM_KEYUP:
case WM_SYSKEYUP:
if (wParam < 256)
io.KeysDown[wParam] = 0;
return 0;
case WM_CHAR:
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
io.AddInputCharacter((unsigned int)wParam);
return 0;
case WM_DEVICECHANGE:
if ((UINT)wParam == DBT_DEVNODES_CHANGED)
g_WantUpdateHasGamepad = true;
return 0;
}
return 0;
}

View File

@@ -0,0 +1,22 @@
// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications)
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
// Implemented features:
// [X] Platform: Clipboard support (for Win32 this is actually part of core imgui)
// [X] Platform:
// shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
#pragma once
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
// Handler for Win32 messages, update mouse/keyboard data.
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
// Intentionally commented out to avoid dragging dependencies on <windows.h> types. You can COPY this line into your .cpp code instead.
/*
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,639 @@
// [DEAR IMGUI]
// This is a slightly modified version of stb_rect_pack.h 1.00.
// Those changes would need to be pushed into nothings/stb:
// - Added STBRP__CDECL
// Grep for [DEAR IMGUI] to find the changes.
// stb_rect_pack.h - v1.00 - public domain - rectangle packing
// Sean Barrett 2014
//
// Useful for e.g. packing rectangular textures into an atlas.
// Does not do rotation.
//
// Not necessarily the awesomest packing method, but better than
// the totally naive one in stb_truetype (which is primarily what
// this is meant to replace).
//
// Has only had a few tests run, may have issues.
//
// More docs to come.
//
// No memory allocations; uses qsort() and assert() from stdlib.
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
//
// This library currently uses the Skyline Bottom-Left algorithm.
//
// Please note: better rectangle packers are welcome! Please
// implement them to the same API, but with a different init
// function.
//
// Credits
//
// Library
// Sean Barrett
// Minor features
// Martins Mozeiko
// github:IntellectualKitty
//
// Bugfixes / warning fixes
// Jeremy Jaussaud
// Fabian Giesen
//
// Version history:
//
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
// 0.99 (2019-02-07) warning fixes
// 0.11 (2017-03-03) return packing success/fail result
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
// 0.09 (2016-08-27) fix compiler warnings
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
// 0.05: added STBRP_ASSERT to allow replacing assert
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
// 0.01: initial release
//
// LICENSE
//
// See end of file for license information.
//////////////////////////////////////////////////////////////////////////////
//
// INCLUDE SECTION
//
#ifndef STB_INCLUDE_STB_RECT_PACK_H
#define STB_INCLUDE_STB_RECT_PACK_H
#define STB_RECT_PACK_VERSION 1
#ifdef STBRP_STATIC
#define STBRP_DEF static
#else
#define STBRP_DEF extern
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct stbrp_context stbrp_context;
typedef struct stbrp_node stbrp_node;
typedef struct stbrp_rect stbrp_rect;
#ifdef STBRP_LARGE_RECTS
typedef int stbrp_coord;
#else
typedef unsigned short stbrp_coord;
#endif
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
// Assign packed locations to rectangles. The rectangles are of type
// 'stbrp_rect' defined below, stored in the array 'rects', and there
// are 'num_rects' many of them.
//
// Rectangles which are successfully packed have the 'was_packed' flag
// set to a non-zero value and 'x' and 'y' store the minimum location
// on each axis (i.e. bottom-left in cartesian coordinates, top-left
// if you imagine y increasing downwards). Rectangles which do not fit
// have the 'was_packed' flag set to 0.
//
// You should not try to access the 'rects' array from another thread
// while this function is running, as the function temporarily reorders
// the array while it executes.
//
// To pack into another rectangle, you need to call stbrp_init_target
// again. To continue packing into the same rectangle, you can call
// this function again. Calling this multiple times with multiple rect
// arrays will probably produce worse packing results than calling it
// a single time with the full rectangle array, but the option is
// available.
//
// The function returns 1 if all of the rectangles were successfully
// packed and 0 otherwise.
struct stbrp_rect
{
// reserved for your use:
int id;
// input:
stbrp_coord w, h;
// output:
stbrp_coord x, y;
int was_packed; // non-zero if valid packing
}; // 16 bytes, nominally
STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
// Initialize a rectangle packer to:
// pack a rectangle that is 'width' by 'height' in dimensions
// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
//
// You must call this function every time you start packing into a new target.
//
// There is no "shutdown" function. The 'nodes' memory must stay valid for
// the following stbrp_pack_rects() call (or calls), but can be freed after
// the call (or calls) finish.
//
// Note: to guarantee best results, either:
// 1. make sure 'num_nodes' >= 'width'
// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
//
// If you don't do either of the above things, widths will be quantized to multiples
// of small integers to guarantee the algorithm doesn't run out of temporary storage.
//
// If you do #2, then the non-quantized algorithm will be used, but the algorithm
// may run out of temporary storage and be unable to pack some rectangles.
STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
// Optionally call this function after init but before doing any packing to
// change the handling of the out-of-temp-memory scenario, described above.
// If you call init again, this will be reset to the default (false).
STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
// Optionally select which packing heuristic the library should use. Different
// heuristics will produce better/worse results for different data sets.
// If you call init again, this will be reset to the default.
enum
{
STBRP_HEURISTIC_Skyline_default=0,
STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
STBRP_HEURISTIC_Skyline_BF_sortHeight
};
//////////////////////////////////////////////////////////////////////////////
//
// the details of the following structures don't matter to you, but they must
// be visible so you can handle the memory allocations for them
struct stbrp_node
{
stbrp_coord x,y;
stbrp_node *next;
};
struct stbrp_context
{
int width;
int height;
int align;
int init_mode;
int heuristic;
int num_nodes;
stbrp_node *active_head;
stbrp_node *free_head;
stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
};
#ifdef __cplusplus
}
#endif
#endif
//////////////////////////////////////////////////////////////////////////////
//
// IMPLEMENTATION SECTION
//
#ifdef STB_RECT_PACK_IMPLEMENTATION
#ifndef STBRP_SORT
#include <stdlib.h>
#define STBRP_SORT qsort
#endif
#ifndef STBRP_ASSERT
#include <assert.h>
#define STBRP_ASSERT assert
#endif
// [DEAR IMGUI] Added STBRP__CDECL
#ifdef _MSC_VER
#define STBRP__NOTUSED(v) (void)(v)
#define STBRP__CDECL __cdecl
#else
#define STBRP__NOTUSED(v) (void)sizeof(v)
#define STBRP__CDECL
#endif
enum
{
STBRP__INIT_skyline = 1
};
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
{
switch (context->init_mode) {
case STBRP__INIT_skyline:
STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
context->heuristic = heuristic;
break;
default:
STBRP_ASSERT(0);
}
}
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
{
if (allow_out_of_mem)
// if it's ok to run out of memory, then don't bother aligning them;
// this gives better packing, but may fail due to OOM (even though
// the rectangles easily fit). @TODO a smarter approach would be to only
// quantize once we've hit OOM, then we could get rid of this parameter.
context->align = 1;
else {
// if it's not ok to run out of memory, then quantize the widths
// so that num_nodes is always enough nodes.
//
// I.e. num_nodes * align >= width
// align >= width / num_nodes
// align = ceil(width/num_nodes)
context->align = (context->width + context->num_nodes-1) / context->num_nodes;
}
}
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
{
int i;
#ifndef STBRP_LARGE_RECTS
STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
#endif
for (i=0; i < num_nodes-1; ++i)
nodes[i].next = &nodes[i+1];
nodes[i].next = NULL;
context->init_mode = STBRP__INIT_skyline;
context->heuristic = STBRP_HEURISTIC_Skyline_default;
context->free_head = &nodes[0];
context->active_head = &context->extra[0];
context->width = width;
context->height = height;
context->num_nodes = num_nodes;
stbrp_setup_allow_out_of_mem(context, 0);
// node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
context->extra[0].x = 0;
context->extra[0].y = 0;
context->extra[0].next = &context->extra[1];
context->extra[1].x = (stbrp_coord) width;
#ifdef STBRP_LARGE_RECTS
context->extra[1].y = (1<<30);
#else
context->extra[1].y = 65535;
#endif
context->extra[1].next = NULL;
}
// find minimum y position if it starts at x1
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
{
stbrp_node *node = first;
int x1 = x0 + width;
int min_y, visited_width, waste_area;
STBRP__NOTUSED(c);
STBRP_ASSERT(first->x <= x0);
#if 0
// skip in case we're past the node
while (node->next->x <= x0)
++node;
#else
STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
#endif
STBRP_ASSERT(node->x <= x0);
min_y = 0;
waste_area = 0;
visited_width = 0;
while (node->x < x1) {
if (node->y > min_y) {
// raise min_y higher.
// we've accounted for all waste up to min_y,
// but we'll now add more waste for everything we've visted
waste_area += visited_width * (node->y - min_y);
min_y = node->y;
// the first time through, visited_width might be reduced
if (node->x < x0)
visited_width += node->next->x - x0;
else
visited_width += node->next->x - node->x;
} else {
// add waste area
int under_width = node->next->x - node->x;
if (under_width + visited_width > width)
under_width = width - visited_width;
waste_area += under_width * (min_y - node->y);
visited_width += under_width;
}
node = node->next;
}
*pwaste = waste_area;
return min_y;
}
typedef struct
{
int x,y;
stbrp_node **prev_link;
} stbrp__findresult;
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
{
int best_waste = (1<<30), best_x, best_y = (1 << 30);
stbrp__findresult fr;
stbrp_node **prev, *node, *tail, **best = NULL;
// align to multiple of c->align
width = (width + c->align - 1);
width -= width % c->align;
STBRP_ASSERT(width % c->align == 0);
// if it can't possibly fit, bail immediately
if (width > c->width || height > c->height) {
fr.prev_link = NULL;
fr.x = fr.y = 0;
return fr;
}
node = c->active_head;
prev = &c->active_head;
while (node->x + width <= c->width) {
int y,waste;
y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
// bottom left
if (y < best_y) {
best_y = y;
best = prev;
}
} else {
// best-fit
if (y + height <= c->height) {
// can only use it if it first vertically
if (y < best_y || (y == best_y && waste < best_waste)) {
best_y = y;
best_waste = waste;
best = prev;
}
}
}
prev = &node->next;
node = node->next;
}
best_x = (best == NULL) ? 0 : (*best)->x;
// if doing best-fit (BF), we also have to try aligning right edge to each node position
//
// e.g, if fitting
//
// ____________________
// |____________________|
//
// into
//
// | |
// | ____________|
// |____________|
//
// then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
//
// This makes BF take about 2x the time
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
tail = c->active_head;
node = c->active_head;
prev = &c->active_head;
// find first node that's admissible
while (tail->x < width)
tail = tail->next;
while (tail) {
int xpos = tail->x - width;
int y,waste;
STBRP_ASSERT(xpos >= 0);
// find the left position that matches this
while (node->next->x <= xpos) {
prev = &node->next;
node = node->next;
}
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
if (y + height <= c->height) {
if (y <= best_y) {
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
best_x = xpos;
STBRP_ASSERT(y <= best_y);
best_y = y;
best_waste = waste;
best = prev;
}
}
}
tail = tail->next;
}
}
fr.prev_link = best;
fr.x = best_x;
fr.y = best_y;
return fr;
}
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
{
// find best position according to heuristic
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
stbrp_node *node, *cur;
// bail if:
// 1. it failed
// 2. the best node doesn't fit (we don't always check this)
// 3. we're out of memory
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
res.prev_link = NULL;
return res;
}
// on success, create new node
node = context->free_head;
node->x = (stbrp_coord) res.x;
node->y = (stbrp_coord) (res.y + height);
context->free_head = node->next;
// insert the new node into the right starting point, and
// let 'cur' point to the remaining nodes needing to be
// stiched back in
cur = *res.prev_link;
if (cur->x < res.x) {
// preserve the existing one, so start testing with the next one
stbrp_node *next = cur->next;
cur->next = node;
cur = next;
} else {
*res.prev_link = node;
}
// from here, traverse cur and free the nodes, until we get to one
// that shouldn't be freed
while (cur->next && cur->next->x <= res.x + width) {
stbrp_node *next = cur->next;
// move the current node to the free list
cur->next = context->free_head;
context->free_head = cur;
cur = next;
}
// stitch the list back in
node->next = cur;
if (cur->x < res.x + width)
cur->x = (stbrp_coord) (res.x + width);
#ifdef _DEBUG
cur = context->active_head;
while (cur->x < context->width) {
STBRP_ASSERT(cur->x < cur->next->x);
cur = cur->next;
}
STBRP_ASSERT(cur->next == NULL);
{
int count=0;
cur = context->active_head;
while (cur) {
cur = cur->next;
++count;
}
cur = context->free_head;
while (cur) {
cur = cur->next;
++count;
}
STBRP_ASSERT(count == context->num_nodes+2);
}
#endif
return res;
}
// [DEAR IMGUI] Added STBRP__CDECL
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
if (p->h > q->h)
return -1;
if (p->h < q->h)
return 1;
return (p->w > q->w) ? -1 : (p->w < q->w);
}
// [DEAR IMGUI] Added STBRP__CDECL
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
{
const stbrp_rect *p = (const stbrp_rect *) a;
const stbrp_rect *q = (const stbrp_rect *) b;
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
}
#ifdef STBRP_LARGE_RECTS
#define STBRP__MAXVAL 0xffffffff
#else
#define STBRP__MAXVAL 0xffff
#endif
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
{
int i, all_rects_packed = 1;
// we use the 'was_packed' field internally to allow sorting/unsorting
for (i=0; i < num_rects; ++i) {
rects[i].was_packed = i;
}
// sort according to heuristic
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
for (i=0; i < num_rects; ++i) {
if (rects[i].w == 0 || rects[i].h == 0) {
rects[i].x = rects[i].y = 0; // empty rect needs no space
} else {
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
if (fr.prev_link) {
rects[i].x = (stbrp_coord) fr.x;
rects[i].y = (stbrp_coord) fr.y;
} else {
rects[i].x = rects[i].y = STBRP__MAXVAL;
}
}
}
// unsort
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
// set was_packed flags and all_rects_packed status
for (i=0; i < num_rects; ++i) {
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
if (!rects[i].was_packed)
all_rects_packed = 0;
}
// return the all_rects_packed status
return all_rects_packed;
}
#endif
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,77 @@
#pragma once
#include <windows.h>
#include <string>
#include <Psapi.h>
#include "Utils/Memory.h"
#include "Utils/Defines.h"
#include "CCSGOInput.h"
#include "Bones.h"
#include "Entity.h"
typedef bool(__fastcall* CreateMove_t)(CCSGOInput* pInput, int nSlot, bool bActive);
inline CreateMove_t CreateMove = NULL;
using CSkeletonInstance__GetBone_t = void(*)(CSkeletonInstance*, CBoneData&, int);
inline CSkeletonInstance__GetBone_t GetBone = NULL;
typedef __int64(__fastcall* FrameStage_t)(__int64 a1, int a2);
inline FrameStage_t FrameStage = NULL;
typedef void(__fastcall* LightingModulationHook_t)(__int64 a1, cAggregateSceneObject* SceneObject, __int64 a3);
inline LightingModulationHook_t oLightingModulation = NULL;
typedef __int64(__fastcall* UpdateSkybox_t)(void*);
inline UpdateSkybox_t OriginalUpdateSkybox = NULL;
class GameOffsets
{
public:
struct VirtualTable
{
uintptr_t dwCSGOInput;
}VTable;
struct GameData
{
uintptr_t dwViewMatrix;
CSkeletonInstance__GetBone_t BoneTransform;
void* ReturnAddress;
uintptr_t WorldModulation;
uintptr_t fnUpdateSky;
}GameData;
};
inline GameOffsets* Offsets = new GameOffsets;
inline BOOL InitializeOffsets()
{
PVOID dwCSGOInput = reinterpret_cast<PVOID>(M::FindPattern(CLIENT_DLL, "48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 8D 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 89 5C 24 20 57 48 83 ec 20"));
PVOID dwViewMatrix = reinterpret_cast<PVOID>(M::FindPattern(CLIENT_DLL, "48 8D ? ? ? ? ? 48 C1 E0 06 48 03 C1 C3 CC CC"));
PVOID GetBoneFunction = reinterpret_cast<PVOID>(M::FindPattern(CLIENT_DLL, "44 8B C0 48 8B D6 48 8B CF E8 ? ? ? ? 48 8B C6"));
PVOID GetModulationFunction = reinterpret_cast<PVOID>(M::FindPattern(SCENESYSTEM_DLL, "48 89 54 24 ? 53 55 41 57"));
PVOID UpdateSky = reinterpret_cast<PVOID>(M::FindPattern(CLIENT_DLL, "48 8B C4 48 89 58 18 48 89 70 20 55 57 41 54 41 55"));
GetBoneFunction = reinterpret_cast<PVOID>(reinterpret_cast<uintptr_t>(GetBoneFunction) + 0x9);
dwCSGOInput = reinterpret_cast<PVOID>(M::GetAbsoluteAddress(reinterpret_cast<uintptr_t>(dwCSGOInput), 3));
dwViewMatrix = reinterpret_cast<PVOID>(M::GetAbsoluteAddress(reinterpret_cast<uintptr_t>(dwViewMatrix), 3));
GetBoneFunction = reinterpret_cast<PVOID>(M::GetAbsoluteAddress(reinterpret_cast<uintptr_t>(GetBoneFunction), 1));
Offsets->GameData.ReturnAddress = reinterpret_cast<PVOID>(M::FindPattern(CLIENT_DLL, "FF 27"));
Offsets->GameData.BoneTransform = (CSkeletonInstance__GetBone_t)GetBoneFunction;
Offsets->GameData.dwViewMatrix = reinterpret_cast<uintptr_t>(dwViewMatrix);
Offsets->VTable.dwCSGOInput = reinterpret_cast<uintptr_t>(dwCSGOInput);
Offsets->GameData.WorldModulation = reinterpret_cast<uintptr_t>(GetModulationFunction);
Offsets->GameData.fnUpdateSky = reinterpret_cast<uintptr_t>(UpdateSky);
GetBone = Offsets->GameData.BoneTransform;
OriginalUpdateSkybox = (UpdateSkybox_t)Offsets->GameData.fnUpdateSky;
return FALSE;
}

View File

@@ -0,0 +1,46 @@
#include "Recoil.h"
#include <iostream>
#include <iomanip>
VOID Recoil(CCSGOInput* Input)
{
if (!MenuConfig::StandloneRCS)
return;
if (Input == nullptr || SDK::LocalPawn == nullptr)
return;
QAngle_t CurrentViewAngles = Input->GetViewAngles();
CUtlVector PunchAngleCache = SDK::LocalPawn->GetCachedAngle();
if (PunchAngleCache.count == 0 || PunchAngleCache.data == nullptr)
return;
QAngle_t* CurrentPunchAngle = &PunchAngleCache.data[PunchAngleCache.count - 1];
if (CurrentPunchAngle == nullptr)
return;
static QAngle_t PreviousPunchAngle = { 0.0f, 0.0f, 0.0f };
if (SDK::LocalPawn->GetShotsFired() > 0)
{
QAngle_t RecoilCompensation;
RecoilCompensation.x = (CurrentPunchAngle->x - PreviousPunchAngle.x) * MenuConfig::RCS_X;
RecoilCompensation.y = (CurrentPunchAngle->y - PreviousPunchAngle.y) * MenuConfig::RCS_Y;
RecoilCompensation.z = 0.0f;
QAngle_t TargetAngles = CurrentViewAngles - RecoilCompensation;
TargetAngles.Normalize();
TargetAngles.Clamp();
Input->SetViewAngle(TargetAngles);
PreviousPunchAngle = *CurrentPunchAngle;
}
else
{
PreviousPunchAngle = { 0.0f, 0.0f, 0.0f };
}
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include "Entity.h"
#include "GameResourceService.h"
#include "qAngles.h"
#include "CCSGOInput.h"
#include "cGameEntitySystem.h"
#include "CheatMenu.h"

View File

@@ -0,0 +1,29 @@
#include "RenderHooks.h"
BOOL PresentHook()
{
uintptr_t AOBPresent = M::FindPattern(L"gameoverlayrenderer64.dll", "48 8B ?? ?? ?? ?? ?? 48 89 ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 89 ?? ?? ?? 89");
uintptr_t Target = M::GetAbsoluteAddress((AOBPresent), 3);
if (AOBPresent == 0)
return FALSE;
PVOID SwapChain = *reinterpret_cast<PVOID*>(Target - 0x28);
void** VirtualTableEntry = *reinterpret_cast<void***>(SwapChain);
oPresent = reinterpret_cast<Present>(VirtualTableEntry[8]);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)oPresent, hkPresent);
DetourTransactionCommit();
return TRUE;
}

View File

@@ -0,0 +1,13 @@
#pragma once
#pragma once
#include "dxgi1_4.h"
#include "Utils/Memory.h"
#include <Psapi.h>
#include "D3D.h"
typedef __int64(__fastcall* tPresentCallback)(__int64 a1);
inline tPresentCallback oPresentCallback = NULL;
inline IDXGISwapChain* g_Swapchain = NULL;

View File

@@ -0,0 +1,201 @@
#pragma once
#include <cstddef>
#include "vector"
#include "../Utils/Hashes.h"
#include "../Utils/Defines.h"
#include "../Utils/Memory.h"
#include "../Utils/FNV1A.h"
using SchemaString_t = const char*;
struct SchemaMetadataEntryData_t;
class CSchemaSystemTypeScope;
class CSchemaType;
struct CSchemaClassBinding
{
CSchemaClassBinding* pParent;
const char* szBinaryName; // ex: C_World
const char* szModuleName; // ex: libclient.so
const char* szClassName; // ex: client
void* pClassInfoOldSynthesized;
void* pClassInfo;
void* pThisModuleBindingPointer;
CSchemaType* pSchemaType;
};
class CSchemaType
{
public:
bool GetSizes(int* pOutSize, uint8_t* unkPtr)
{
return M::CallVFunc<bool, 3U>(this, pOutSize, unkPtr);
}
public:
bool GetSize(int* out_size)
{
uint8_t smh = 0;
return GetSizes(out_size, &smh);
}
public:
void* pVtable; // 0x0000
const char* szName; // 0x0008
CSchemaSystemTypeScope* pSystemTypeScope; // 0x0010
uint8_t nTypeCategory; // ETypeCategory 0x0018
uint8_t nAatomicCategory; // EAtomicCategory 0x0019
};
struct SchemaClassFieldData_t
{
SchemaString_t szName; // 0x0000
CSchemaType* pSchemaType; // 0x0008
std::uint32_t nSingleInheritanceOffset; // 0x0010
std::int32_t nMetadataSize; // 0x0014
SchemaMetadataEntryData_t* pMetaData; // 0x0018
};
struct SchemaClassInfoData_t;
struct SchemaBaseClassInfoData_t
{
int32_t nOffset;
SchemaClassInfoData_t* pClass;
};
struct SchemaClassInfoData_t
{
private:
void* pVtable; // 0x0000
public:
const char* szName; // 0x0008
char* szDescription; // 0x0010
int m_nSize; // 0x0018
std::int16_t nFieldSize; // 0x001C
std::int16_t nStaticSize; // 0x001E
std::int16_t nMetadataSize; // 0x0020
std::uint8_t nAlignOf; // 0x0022
std::uint8_t nBaseClassesCount; // 0x0023
char pad2[0x4]; // 0x0024
SchemaClassFieldData_t* pFields; // 0x0028
char pad3[0x8]; // 0x0030
SchemaBaseClassInfoData_t* pBaseClasses; // 0x0038
char pad4[0x28]; // 0x0040
bool InheritsFrom(SchemaClassInfoData_t* pClassInfo)
{
if (pClassInfo == this && pClassInfo != nullptr)
return true;
else if (pBaseClasses == nullptr || pClassInfo == nullptr)
return false;
for (int i = 0; i < nBaseClassesCount; i++)
{
auto& baseClass = pBaseClasses[i];
if (baseClass.pClass->InheritsFrom(pClassInfo))
return true;
}
return false;
}
};
struct SchemaEnumeratorInfoData_t
{
SchemaString_t szName;
union
{
unsigned char value_char;
unsigned short value_short;
unsigned int value_int;
unsigned long long value;
};
MEM_PAD(0x10); // 0x0010
};
class CSchemaEnumInfo
{
public:
SchemaEnumeratorInfoData_t enumInfoData;
};
class CSchemaEnumBinding
{
public:
virtual const char* GetBindingName() = 0;
virtual CSchemaClassBinding* AsClassBinding() = 0;
virtual CSchemaEnumBinding* AsEnumBinding() = 0;
virtual const char* GetBinaryName() = 0;
virtual const char* GetProjectName() = 0;
public:
char* szBindingName_; // 0x0008
char* szDllName_; // 0x0010
std::int8_t nAlign_; // 0x0018
MEM_PAD(0x3); // 0x0019
std::int16_t nSize_; // 0x001C
std::int16_t nFlags_; // 0x001E
SchemaEnumeratorInfoData_t* pEnumInfo_;
MEM_PAD(0x8); // 0x0028
CSchemaSystemTypeScope* pTypeScope_; // 0x0030
MEM_PAD(0x8); // 0x0038
std::int32_t unk1_; // 0x0040
};
class CSchemaSystemTypeScope
{
public:
void FindDeclaredClass(SchemaClassInfoData_t** pReturnClass, const char* szClassName)
{
return M::CallVFunc<void, 2U>(this, pReturnClass, szClassName);
}
CSchemaType* FindSchemaTypeByName(const char* szName, std::uintptr_t* pSchema)
{
return M::CallVFunc<CSchemaType*, 4U>(this, szName, pSchema);
}
CSchemaType* FindTypeDeclaredClass(const char* szName)
{
return M::CallVFunc<CSchemaType*, 5U>(this, szName);
}
CSchemaType* FindTypeDeclaredEnum(const char* szName)
{
return M::CallVFunc<CSchemaType*, 6U>(this, szName);
}
CSchemaClassBinding* FindRawClassBinding(const char* szName)
{
return M::CallVFunc<CSchemaClassBinding*, 7U>(this, szName);
}
void* pVtable; // 0x0000
char szName[256U]; // 0x0008
MEM_PAD(SCHEMASYSTEMTYPESCOPE_OFF1); // 0x0108
CUtlTSHash<CSchemaClassBinding*, 256, unsigned int> hashClasses; // 0x0588
MEM_PAD(SCHEMASYSTEMTYPESCOPE_OFF2); // 0x05C8
CUtlTSHash<CSchemaEnumBinding*, 256, unsigned int> hashEnumes; // 0x2DD0
};
class ISchemaSystem
{
public:
CSchemaSystemTypeScope* FindTypeScopeForModule(const char* m_module_name)
{
return M::CallVFunc<CSchemaSystemTypeScope*, 13U>(this, m_module_name, nullptr);
}
private:
MEM_PAD(SCHEMASYSTEM_TYPE_SCOPES_OFFSET); // 0x0000
public:
// table of type scopes
std::vector<CSchemaSystemTypeScope*> vecTypeScopes; // SCHEMASYSTEM_TYPE_SCOPES_OFFSET
};

View File

@@ -0,0 +1,95 @@
#pragma once
#include "Schema.h"
#include "string"
#include "Utils/FNV1A.h"
#include "../Utils/Interfaces.h"
#define MAX_PATH 260
struct SchemaData_t
{
FNV1A_t uHashedFieldName;
std::uint32_t uOffset;
};
inline std::vector<SchemaData_t> SchemaData;
inline bool SetupSchema(const char* szModuleName)
{
CSchemaSystemTypeScope* pTypeScope = I::SchemaSystem->FindTypeScopeForModule(szModuleName);
if (pTypeScope == nullptr)
return false;
const int nTableSize = pTypeScope->hashClasses.Count();
UtlTSHashHandle_t* pElements = new UtlTSHashHandle_t[nTableSize + 1U];
const auto nElements = pTypeScope->hashClasses.GetElements(0, nTableSize, pElements);
for (int i = 0; i < nElements; i++)
{
const UtlTSHashHandle_t hElement = pElements[i];
if (hElement == 0)
continue;
CSchemaClassBinding* pClassBinding = pTypeScope->hashClasses[hElement];
if (pClassBinding == nullptr)
continue;
SchemaClassInfoData_t* pDeclaredClassInfo;
pTypeScope->FindDeclaredClass(&pDeclaredClassInfo, pClassBinding->szBinaryName);
if (pDeclaredClassInfo == nullptr)
continue;
if (pDeclaredClassInfo->nFieldSize == 0)
continue;
for (auto j = 0; j < pDeclaredClassInfo->nFieldSize; j++)
{
SchemaClassFieldData_t* pFields = pDeclaredClassInfo->pFields;
std::string szFieldClassBuffer = std::string(pClassBinding->szBinaryName) + "->" + pFields[j].szName;
SchemaData.emplace_back(FNV1A::Hash(szFieldClassBuffer.c_str()), pFields[j].nSingleInheritanceOffset);
std::string szFieldBuffer = std::string(pFields[j].pSchemaType->szName) + " " + pFields[j].szName + " = 0x" + std::to_string(pFields[j].nSingleInheritanceOffset) + "\n";
}
}
delete[] pElements;
return true;
}
inline std::uint32_t GetOffset(const FNV1A_t uHashedFieldName)
{
if (const auto it = std::ranges::find_if(SchemaData, [uHashedFieldName](const SchemaData_t& data)
{ return data.uHashedFieldName == uHashedFieldName; });
it != SchemaData.end())
return it->uOffset;
return 0U;
}
#define SCHEMA_ADD_OFFSET(TYPE, NAME, OFFSET) \
inline std::add_lvalue_reference_t<TYPE> NAME() \
{ \
static const std::uint32_t uOffset = OFFSET; \
return *reinterpret_cast<std::add_pointer_t<TYPE>>(reinterpret_cast<std::uint8_t*>(this) + (uOffset)); \
}
#define SCHEMA_ADD_POFFSET(TYPE, NAME, OFFSET) \
inline std::add_pointer_t<TYPE> NAME() \
{ \
const static std::uint32_t uOffset = OFFSET; \
return reinterpret_cast<std::add_pointer_t<TYPE>>(reinterpret_cast<std::uint8_t*>(this) + (uOffset)); \
}
#define SCHEMA_ADD_FIELD_OFFSET(TYPE, NAME, FIELD, ADDITIONAL) SCHEMA_ADD_OFFSET(TYPE, NAME, GetOffset(FNV1A::HashConst(FIELD)) + ADDITIONAL)
#define SCHEMA_ADD_FIELD(TYPE, NAME, FIELD) SCHEMA_ADD_FIELD_OFFSET(TYPE, NAME, FIELD, 0U)
#define SCHEMA_ADD_PFIELD_OFFSET(TYPE, NAME, FIELD, ADDITIONAL) SCHEMA_ADD_POFFSET(TYPE, NAME, GetOffset(FNV1A::HashConst(FIELD)) + ADDITIONAL)
#define SCHEMA_ADD_PFIELD(TYPE, NAME, FIELD) SCHEMA_ADD_PFIELD_OFFSET(TYPE, NAME, FIELD, 0U)

View File

@@ -0,0 +1,57 @@
#pragma once
#include "Schema/Schema.h"
#include "Utils/Defines.h"
#include "Utils/Interfaces.h"
#include "Tracing.h"
inline bool Setup()
{
bool bSuccess = true;
const void* hDbgHelp = M::GetModuleBaseHandle(DBGHELP_DLL);
const void* hTier0 = M::GetModuleBaseHandle(TIER0_DLL);
if (hDbgHelp == nullptr || hTier0 == nullptr)
return false;
const auto pTier0Handle = M::GetModuleBaseHandle(TIER0_DLL);
if (pTier0Handle == nullptr)
return false;
const auto pSchemaSystemRegisterList = I::GetRegisterList(SCHEMASYSTEM_DLL);
if (pSchemaSystemRegisterList == nullptr)
return false;
I::SchemaSystem = I::Capture<ISchemaSystem>(pSchemaSystemRegisterList, SCHEMA_SYSTEM);
bSuccess &= (I::SchemaSystem != nullptr);
const auto pEngineRegisterList = I::GetRegisterList(ENGINE2_DLL);
if (pEngineRegisterList == nullptr)
return false;
I::GameResourceService = I::Capture<IGameResourceService>(pEngineRegisterList, GAME_RESOURCE_SERVICE_CLIENT);
bSuccess &= (I::GameResourceService != nullptr);
I::Engine = I::Capture<IEngineClient>(pEngineRegisterList, SOURCE2_ENGINE_TO_CLIENT);
bSuccess &= (I::Engine != nullptr);
I::Trace = *reinterpret_cast<Tracing**>(M::GetAbsoluteAddress(M::FindPattern(CLIENT_DLL, "4C 8B 3D ? ? ? ? 24 C9 0C 49 66 0F 7F 45 ?"), 0x3));
bSuccess &= (I::Trace != nullptr);
I::MemAlloc = *reinterpret_cast<IMemAlloc**>(M::GetExportAddress(pTier0Handle, "g_pMemAlloc"));
bSuccess &= (I::MemAlloc != nullptr);
M::fnUtlBufferInit = reinterpret_cast<decltype(M::fnUtlBufferInit)>(M::GetExportAddress(hTier0, "??0CUtlBuffer@@QEAA@HHH@Z"));
bSuccess &= (M::fnUtlBufferInit != nullptr);
M::fnUtlBufferPutString = reinterpret_cast<decltype(M::fnUtlBufferPutString)>(M::GetExportAddress(hTier0, "?PutString@CUtlBuffer@@QEAAXPEBD@Z"));
bSuccess &= (M::fnUtlBufferPutString != nullptr);
M::fnUtlBufferEnsureCapacity = reinterpret_cast<decltype(M::fnUtlBufferEnsureCapacity)>(M::GetExportAddress(hTier0, "?EnsureCapacity@CUtlBuffer@@QEAAXH@Z"));
bSuccess &= (M::fnUtlBufferEnsureCapacity != nullptr);
return bSuccess;
}

View File

@@ -0,0 +1,222 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{25590663-3b18-4911-a427-8a30f872c3d0}</ProjectGuid>
<RootNamespace>SourceEngine</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;SOURCEENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;SOURCEENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;SOURCEENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>NDEBUG;SOURCEENGINE_EXPORTS;_WINDOWS;_USRDLL;_M_IX86_FP=2;__AVX__;__AVX2__;__AVX512F__
;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpplatest</LanguageStandard>
<ControlFlowGuard>false</ControlFlowGuard>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Aimbot.cpp" />
<ClCompile Include="CheatMenu.cpp" />
<ClCompile Include="D3D.cpp" />
<ClCompile Include="DLLMain.cpp">
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</WholeProgramOptimization>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Entity.cpp" />
<ClCompile Include="ESP.cpp" />
<ClCompile Include="Hooks.cpp" />
<ClCompile Include="ImGui\imgui.cpp" />
<ClCompile Include="ImGui\imgui_demo.cpp" />
<ClCompile Include="ImGui\imgui_draw.cpp" />
<ClCompile Include="ImGui\imgui_impl_dx11.cpp" />
<ClCompile Include="ImGui\imgui_impl_win32.cpp" />
<ClCompile Include="ImGui\imgui_widgets.cpp" />
<ClCompile Include="Recoil.cpp" />
<ClCompile Include="RenderHooks.cpp" />
<ClCompile Include="TriggerBot.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Aimbot.h" />
<ClInclude Include="Bones.h" />
<ClInclude Include="CCSGOInput.h" />
<ClInclude Include="cGameEntitySystem.h" />
<ClInclude Include="CheatMenu.h" />
<ClInclude Include="Colors.h" />
<ClInclude Include="CRC.h" />
<ClInclude Include="D3D.h" />
<ClInclude Include="Entity.h" />
<ClInclude Include="EntityHandle.h" />
<ClInclude Include="ESP.h" />
<ClInclude Include="GameResourceService.h" />
<ClInclude Include="Hooks.h" />
<ClInclude Include="iemalloc.h" />
<ClInclude Include="iEngineClient.h" />
<ClInclude Include="ImGui\imconfig.h" />
<ClInclude Include="ImGui\imgui.h" />
<ClInclude Include="ImGui\imgui_impl_dx11.h" />
<ClInclude Include="ImGui\imgui_impl_win32.h" />
<ClInclude Include="ImGui\imgui_internal.h" />
<ClInclude Include="ImGui\imstb_rectpack.h" />
<ClInclude Include="ImGui\imstb_textedit.h" />
<ClInclude Include="ImGui\imstb_truetype.h" />
<ClInclude Include="Offsets.h" />
<ClInclude Include="qAngles.h" />
<ClInclude Include="Recoil.h" />
<ClInclude Include="RenderHooks.h" />
<ClInclude Include="Schema\Schema.h" />
<ClInclude Include="Schema\SchemaSetup.h" />
<ClInclude Include="Setup.h" />
<ClInclude Include="TextFont.h" />
<ClInclude Include="Tracing.h" />
<ClInclude Include="TriggerBot.h" />
<ClInclude Include="UserCMD.h" />
<ClInclude Include="Utils\cVector.h" />
<ClInclude Include="Utils\Defines.h" />
<ClInclude Include="Utils\FNV1A.h" />
<ClInclude Include="Utils\Hashes.h" />
<ClInclude Include="Utils\Interfaces.h" />
<ClInclude Include="Utils\Memory.h" />
<ClInclude Include="Utils\ReturnAddressr.h" />
<ClInclude Include="utlbuffer.h" />
<ClInclude Include="W2S.h" />
<ClInclude Include="WeaponFont.h" />
</ItemGroup>
<ItemGroup>
<MASM Include="Utils\spoofer_stub.asm" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>

View File

@@ -0,0 +1,251 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Utils">
<UniqueIdentifier>{2702f9fc-ed17-412c-ab21-926dc6c89477}</UniqueIdentifier>
</Filter>
<Filter Include="SDK">
<UniqueIdentifier>{ab201c3c-380a-4ea4-875b-5118a55c5e87}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\IGameResourceService">
<UniqueIdentifier>{036aa78f-500a-476e-b033-f36598413d1f}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\Entity">
<UniqueIdentifier>{14643fa4-9016-46d5-ac19-9a9cf11b135e}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\Engine">
<UniqueIdentifier>{6f9a922c-64e2-46b1-a623-4a241db44c2e}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\Hooks">
<UniqueIdentifier>{279830db-172f-46e5-9bce-2b41de4bf3f7}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\CCSGOInput">
<UniqueIdentifier>{c20474ee-f9a2-484c-ac52-bf383466effa}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\UserCMD">
<UniqueIdentifier>{379e5b5b-4ca6-42da-8192-58e45f306346}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\Offsets">
<UniqueIdentifier>{9193e754-f5ad-449f-9b21-435d4ef42692}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\Trace">
<UniqueIdentifier>{86b31092-5482-4077-bcae-7beaa24d2e7e}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\WorldProjection">
<UniqueIdentifier>{aea41ca3-ba44-425c-85d6-e3353a6f5e92}</UniqueIdentifier>
</Filter>
<Filter Include="ImGui">
<UniqueIdentifier>{504e36d6-12a5-42ae-8c27-337861fb90a4}</UniqueIdentifier>
</Filter>
<Filter Include="Render">
<UniqueIdentifier>{468ffd96-9d0c-457f-b743-cf2fa653bac6}</UniqueIdentifier>
</Filter>
<Filter Include="Features">
<UniqueIdentifier>{f959c28f-210f-49dd-ab51-3e8be858ffdd}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files\Schema">
<UniqueIdentifier>{ce3a9508-e986-4c3f-bca6-3475f62bc14a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="DLLMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Entity.cpp">
<Filter>SDK\Entity</Filter>
</ClCompile>
<ClCompile Include="Hooks.cpp">
<Filter>SDK\Hooks</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui_demo.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui_draw.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui_impl_dx11.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui_impl_win32.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui_widgets.cpp">
<Filter>ImGui</Filter>
</ClCompile>
<ClCompile Include="RenderHooks.cpp">
<Filter>SDK\Hooks</Filter>
</ClCompile>
<ClCompile Include="D3D.cpp">
<Filter>Render</Filter>
</ClCompile>
<ClCompile Include="CheatMenu.cpp">
<Filter>Render</Filter>
</ClCompile>
<ClCompile Include="ESP.cpp">
<Filter>Render</Filter>
</ClCompile>
<ClCompile Include="Aimbot.cpp">
<Filter>Features</Filter>
</ClCompile>
<ClCompile Include="Recoil.cpp">
<Filter>Features</Filter>
</ClCompile>
<ClCompile Include="TriggerBot.cpp">
<Filter>Features</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Utils\Defines.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\FNV1A.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\Hashes.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\Interfaces.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\Memory.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Utils\ReturnAddressr.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="Setup.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Utils\cVector.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="GameResourceService.h">
<Filter>SDK\IGameResourceService</Filter>
</ClInclude>
<ClInclude Include="Schema\Schema.h">
<Filter>Resource Files\Schema</Filter>
</ClInclude>
<ClInclude Include="Schema\SchemaSetup.h">
<Filter>Resource Files\Schema</Filter>
</ClInclude>
<ClInclude Include="EntityHandle.h">
<Filter>SDK\Entity</Filter>
</ClInclude>
<ClInclude Include="cGameEntitySystem.h">
<Filter>SDK\Entity</Filter>
</ClInclude>
<ClInclude Include="Entity.h">
<Filter>SDK\Entity</Filter>
</ClInclude>
<ClInclude Include="iEngineClient.h">
<Filter>SDK\Engine</Filter>
</ClInclude>
<ClInclude Include="Hooks.h">
<Filter>SDK\Hooks</Filter>
</ClInclude>
<ClInclude Include="Bones.h">
<Filter>SDK\Entity</Filter>
</ClInclude>
<ClInclude Include="CCSGOInput.h">
<Filter>SDK\CCSGOInput</Filter>
</ClInclude>
<ClInclude Include="qAngles.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="UserCMD.h">
<Filter>SDK\UserCMD</Filter>
</ClInclude>
<ClInclude Include="Offsets.h">
<Filter>SDK\Offsets</Filter>
</ClInclude>
<ClInclude Include="Tracing.h">
<Filter>SDK\Trace</Filter>
</ClInclude>
<ClInclude Include="W2S.h">
<Filter>SDK\WorldProjection</Filter>
</ClInclude>
<ClInclude Include="ImGui\imconfig.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imgui.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imgui_impl_dx11.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imgui_impl_win32.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imgui_internal.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imstb_rectpack.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imstb_textedit.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imstb_truetype.h">
<Filter>ImGui</Filter>
</ClInclude>
<ClInclude Include="RenderHooks.h">
<Filter>SDK\Hooks</Filter>
</ClInclude>
<ClInclude Include="D3D.h">
<Filter>Render</Filter>
</ClInclude>
<ClInclude Include="WeaponFont.h">
<Filter>Render</Filter>
</ClInclude>
<ClInclude Include="TextFont.h">
<Filter>Render</Filter>
</ClInclude>
<ClInclude Include="CheatMenu.h">
<Filter>Render</Filter>
</ClInclude>
<ClInclude Include="ESP.h">
<Filter>Render</Filter>
</ClInclude>
<ClInclude Include="Aimbot.h">
<Filter>Features</Filter>
</ClInclude>
<ClInclude Include="Recoil.h">
<Filter>Features</Filter>
</ClInclude>
<ClInclude Include="Colors.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="TriggerBot.h">
<Filter>Features</Filter>
</ClInclude>
<ClInclude Include="CRC.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="utlbuffer.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="iemalloc.h">
<Filter>Utils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<MASM Include="Utils\spoofer_stub.asm">
<Filter>Utils</Filter>
</MASM>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,277 @@
#pragma once
#include <array>
#include "cstdint"
#include "Utils/ReturnAddressr.h"
#include "Utils/cVector.h"
#include "Entity.h"
#include "cGameEntitySystem.h"
#include "Offsets.h"
#define CLIP_TRACE_TO_PLAYERS "48 8B C4 55 56 48 8D A8 58 FF FF FF 48 81 EC 98 01 00 00 48"
#define TRACE_SHAPE "48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 55 41 56 48 8D AC 24"
#define COMBINE(x, y) x##y
#define COMBINE2(x, y) COMBINE(x, y)
#define PAD_CLASS_DEBUG(sz) int COMBINE2(pad_, __COUNTER__)[sz];
#define CS2_PAD( number, size ) \
private: \
[[maybe_unused]] std::array< std::byte, size > m_unknown_##number{ }; \
public:
enum Contents_t
{
CONTENTS_EMPTY = 0,
CONTENTS_SOLID = 0x1,
CONTENTS_WINDOW = 0x2,
CONTENTS_AUX = 0x4,
CONTENTS_GRATE = 0x8,
CONTENTS_SLIME = 0x10,
CONTENTS_WATER = 0x20,
CONTENTS_BLOCKLOS = 0x40,
CONTENTS_OPAQUE = 0x80,
CONTENTS_TESTFOGVOLUME = 0x100,
CONTENTS_UNUSED = 0x200,
CONTENTS_BLOCKLIGHT = 0x400,
CONTENTS_TEAM1 = 0x800,
CONTENTS_TEAM2 = 0x1000,
CONTENTS_IGNORE_NODRAW_OPAQUE = 0x2000,
CONTENTS_MOVEABLE = 0x4000,
CONTENTS_AREAPORTAL = 0x8000,
CONTENTS_PLAYERCLIP = 0x10000,
CONTENTS_MONSTERCLIP = 0x20000,
CONTENTS_CURRENT_0 = 0x40000,
CONTENTS_CURRENT_90 = 0x80000,
CONTENTS_CURRENT_180 = 0x100000,
CONTENTS_CURRENT_270 = 0x200000,
CONTENTS_CURRENT_UP = 0x400000,
CONTENTS_CURRENT_DOWN = 0x800000,
CONTENTS_ORIGIN = 0x1000000,
CONTENTS_MONSTER = 0x2000000,
CONTENTS_DEBRIS = 0x4000000,
CONTENTS_DETAIL = 0x8000000,
CONTENTS_TRANSLUCENT = 0x10000000,
CONTENTS_LADDER = 0x20000000,
CONTENTS_HITBOX = 0x40000000,
};
enum Masks_t
{
MASK_ALL = 0xFFFFFFFF,
MASK_SOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_PLAYERSOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_NPCSOLID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_NPCFLUID = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE,
MASK_WATER = CONTENTS_WATER | CONTENTS_MOVEABLE | CONTENTS_SLIME,
MASK_OPAQUE = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_OPAQUE,
MASK_OPAQUE_AND_NPCS = MASK_OPAQUE | CONTENTS_MONSTER,
MASK_BLOCKLOS = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_BLOCKLOS,
MASK_BLOCKLOS_AND_NPCS = MASK_BLOCKLOS | CONTENTS_MONSTER,
MASK_VISIBLE = MASK_OPAQUE | CONTENTS_IGNORE_NODRAW_OPAQUE,
MASK_VISIBLE_AND_NPCS = MASK_OPAQUE_AND_NPCS | CONTENTS_IGNORE_NODRAW_OPAQUE,
MASK_SHOT = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE | CONTENTS_HITBOX,
MASK_SHOT_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_DEBRIS,
MASK_SHOT_HULL = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE,
MASK_SHOT_PORTAL = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER,
MASK_SOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_GRATE,
MASK_PLAYERSOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_PLAYERCLIP | CONTENTS_GRATE,
MASK_NPCSOLID_BRUSHONLY = CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE,
MASK_NPCWORLDSTATIC = CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE,
MASK_NPCWORLDSTATIC_FLUID = CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP,
MASK_SPLITAREPORTAL = CONTENTS_WATER | CONTENTS_SLIME,
MASK_CURRENT = CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN,
MASK_DEADSOLID = CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_GRATE,
};
enum
{
SURF_LIGHT = 0x0001,
SURF_SKY2D = 0x0002,
SURF_SKY = 0x0004,
SURF_WARP = 0x0008,
SURF_TRANS = 0x0010,
SURF_NOPORTAL = 0x0020,
SURF_TRIGGER = 0x0040,
SURF_NODRAW = 0x0080,
SURF_HINT = 0x0100,
SURF_SKIP = 0x0200,
SURF_NOLIGHT = 0x0400,
SURF_BUMPLIGHT = 0x0800,
SURF_NOSHADOWS = 0x1000,
SURF_NODECALS = 0x2000,
SURF_NOPAINT = SURF_NODECALS,
SURF_NOCHOP = 0x4000,
SURF_HITBOX = 0x8000
};
struct Ray_t
{
Vector_t Start = Vector_t(0, 0, 0);
Vector_t End = Vector_t(0, 0, 0);
Vector_t Mins = Vector_t(0, 0, 0);
Vector_t Maxs = Vector_t(0, 0, 0);
char __pad0000[0x4];
std::uint8_t UnkownType = 0x0;
};
static_assert(sizeof(Ray_t) == 0x38);
class Trace_Filter_t
{
public:
char __pad0000[0x8];
std::uint64_t trace_mask;
std::uint64_t null_it[2];
std::uint32_t SkipHandles[4];
std::uint16_t Collisions[2];
std::uint16_t N0000011C;
std::uint8_t layer;
std::uint8_t N00000104;
std::uint8_t null_it3;
};
struct C_TraceHitboxData
{
CS2_PAD(0, 0x38);
int m_hitgroup{ };
};
class Game_Trace_t
{
public:
void* Surface;
C_BaseEntity* HitEntity;
C_TraceHitboxData* HitboxData;
CS2_PAD(0, 0x38);
std::uint32_t Contents;
CS2_PAD(1, 0x24);
Vector_t m_start_pos, m_end_pos, m_normal, m_pos;
MEM_PAD(0x4);
float Fraction;
MEM_PAD(0x6);
bool m_all_solid;
CS2_PAD(4, 0x4D);
};
struct UpdateValueT
{
float previousLenght{ };
float currentLenght{ };
CS2_PAD(0, 0x8);
std::int16_t handleIdx{ };
CS2_PAD(1, 0x6);
};
struct trace_arr_element_t {
CS2_PAD(0, 0x30);
};
struct Trace_Data_t
{
std::int32_t m_uk1{ };
float m_uk2{ 52.0f };
void* m_arr_pointer{ };
std::int32_t m_uk3{ 128 };
std::int32_t m_uk4{ static_cast<std::int32_t>(0x80000000) };
std::array< trace_arr_element_t, 0x80 > m_arr = { };
CS2_PAD(0, 0x8);
std::int64_t m_num_update{ };
void* m_pointer_update_value{ };
CS2_PAD(1, 0xC8);
Vector_t m_start{ }, m_end{ };
CS2_PAD(2, 0x50);
};
class Tracing
{
public:
void InitializeTraceInfo(Game_Trace_t* const Hit)
{
using InitializeTraceInfoFunction = void(__fastcall*)(Game_Trace_t*);
static InitializeTraceInfoFunction InitializeTraceInfoFn = nullptr;
if (!InitializeTraceInfoFn)
InitializeTraceInfoFn = reinterpret_cast<InitializeTraceInfoFunction>(M::FindPattern(CLIENT_DLL, "48 89 5C 24 08 57 48 83 EC 20 48 8B D9 33 FF 48 8B 0D"));
FakeReturnAddress(Offsets->GameData.ReturnAddress, InitializeTraceInfoFn, Hit);
}
void InitializeTrace(Game_Trace_t& Trace)
{
using InitializeTraceFunction = void(__fastcall*)(Game_Trace_t&);
static InitializeTraceFunction InitializeTraceFn = nullptr;
if (!InitializeTraceFn)
InitializeTraceFn = reinterpret_cast<InitializeTraceFunction>(M::FindPattern(CLIENT_DLL, "48 89 5C 24 08 57 48 83 EC 20 48 8B D9 33 FF 48 8B 0D"));
FakeReturnAddress<void, Game_Trace_t&>(Offsets->GameData.ReturnAddress, InitializeTraceFn, Trace);
}
void Init(Trace_Filter_t& Filter, C_CSPlayerPawn* Skip, uint64_t Mask, uint8_t Layer, uint16_t Idk)
{
using InitTraceFilterFunction = Trace_Filter_t * (__fastcall*)(Trace_Filter_t&, void*, uint64_t, uint8_t, uint16_t);
static InitTraceFilterFunction InitTraceFilterFn = nullptr;
if (InitTraceFilterFn == nullptr)
InitTraceFilterFn = reinterpret_cast<InitTraceFilterFunction>(M::FindPattern(CLIENT_DLL, ("48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 0F B6 41 37 33")));
FakeReturnAddress<Trace_Filter_t*, Trace_Filter_t&, void*, uint64_t, uint8_t, uint16_t>(Offsets->GameData.ReturnAddress, InitTraceFilterFn, Filter, Skip, Mask, Layer, Idk);
}
void ClipTraceToPlayers(Vector_t& Start, Vector_t& End, Trace_Filter_t* Filter, Game_Trace_t* Trace, float Min, int Length, float Max)
{
using ClipTraceToPlayersFunction = void(__fastcall*)(Vector_t&, Vector_t&, Trace_Filter_t*, Game_Trace_t*, float, int, float);
static ClipTraceToPlayersFunction ClipTraceToPlayersFn = nullptr;
if (ClipTraceToPlayersFn == nullptr)
{
ClipTraceToPlayersFn = reinterpret_cast<ClipTraceToPlayersFunction>(M::FindPattern(CLIENT_DLL, CLIP_TRACE_TO_PLAYERS));
if (ClipTraceToPlayersFn == nullptr)
ClipTraceToPlayersFn = reinterpret_cast<ClipTraceToPlayersFunction>(M::FindPattern(CLIENT_DLL, "48 8B C4 55 56 48 8D A8 58"));
}
FakeReturnAddress<void, Vector_t&, Vector_t&, Trace_Filter_t*, Game_Trace_t*, float, int, float>(Offsets->GameData.ReturnAddress, ClipTraceToPlayersFn, Start, End, Filter, Trace, Min, Length, Max);
}
static void GetTraceInfo(Trace_Data_t* Trace, Game_Trace_t* Hit, const float UnknownFloat, void* Unknown)
{
using GetTraceInfoFunction = void(__fastcall*)(Trace_Data_t*, Game_Trace_t*, float, void*);
static GetTraceInfoFunction GetTraceInfoFn = nullptr;
if (GetTraceInfoFn == nullptr)
GetTraceInfoFn = reinterpret_cast<GetTraceInfoFunction>(M::FindPattern(CLIENT_DLL, ("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 60 48 8B E9 0F")));
FakeReturnAddress<void, Trace_Data_t*, Game_Trace_t*, float, void*>(Offsets->GameData.ReturnAddress, GetTraceInfoFn, Trace, Hit, UnknownFloat, Unknown);
}
static bool HandleBulletPenetration(Trace_Data_t* const Trace, void* Stats, UpdateValueT* const ModValue, const bool draw_showimpacts = false)
{
using HandleBulletPenetrationFunction = bool(__fastcall*)(Trace_Data_t*, void*, UpdateValueT*, void*, void*, void*, void*, void*, bool);
static HandleBulletPenetrationFunction HandleBulletPenetrationFn = nullptr;
if (HandleBulletPenetrationFn == nullptr)
HandleBulletPenetrationFn = reinterpret_cast<HandleBulletPenetrationFunction>(M::FindPattern(CLIENT_DLL, ("48 8B C4 44 89 48 20 55 57 41 55")));
return FakeReturnAddress<bool, Trace_Data_t*, void*, UpdateValueT*, void*, void*, void*, void*, void*, bool>(Offsets->GameData.ReturnAddress, HandleBulletPenetrationFn, Trace, Stats, ModValue, nullptr, nullptr, nullptr, nullptr, nullptr, draw_showimpacts);
}
static void CreateTrace(Trace_Data_t* const Trace, const Vector_t Start, const Vector_t End, const Trace_Filter_t& Filter, const int PenetrationCount)
{
using CreateTraceFunction = void(__fastcall*)(Trace_Data_t*, Vector_t, Vector_t, Trace_Filter_t, int);
static CreateTraceFunction CreateTraceFn = nullptr;
if (CreateTraceFn == nullptr)
CreateTraceFn = reinterpret_cast<CreateTraceFunction>(M::FindPattern(CLIENT_DLL, ("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 83 EC 40 F2")));
FakeReturnAddress<void, Trace_Data_t*, Vector_t, Vector_t, Trace_Filter_t, int>(Offsets->GameData.ReturnAddress, CreateTraceFn, Trace, Start, End, Filter, PenetrationCount);
}
void TraceShape(Ray_t& Ray, Vector_t* Start, Vector_t* End, Trace_Filter_t Filter, Game_Trace_t& Trace)
{
using TraceShapeFunction = bool(__fastcall*)(void*, Ray_t&, Vector_t*, Vector_t*, Trace_Filter_t, Game_Trace_t&);
static TraceShapeFunction TraceShapeFn = nullptr;
if (TraceShapeFn == nullptr)
TraceShapeFn = reinterpret_cast<TraceShapeFunction>(M::FindPattern(CLIENT_DLL, "48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 48 89 4C 24 08 55 41 54 41 55 41 56 41 57 48 8D"));
FakeReturnAddress<bool, void*, Ray_t&, Vector_t*, Vector_t*, Trace_Filter_t, Game_Trace_t&>(Offsets->GameData.ReturnAddress, TraceShapeFn, this, Ray, Start, End, Filter, Trace);
}
};

View File

@@ -0,0 +1 @@
#include "TriggerBot.h"

View File

@@ -0,0 +1,34 @@
#pragma once
#include "Windows.h"
#include "Entity.h"
#include "cGameEntitySystem.h"
#include "Tracing.h"
#include "CheatMenu.h"
#include "CRC.h"
extern inline QAngle_t CalculateAngleScalar(const Vector_t& src, const Vector_t& dst);
VOID TriggerBot(CCSGOInput* pInput)
{
if (SDK::Cmd == nullptr || MenuConfig::TriggerBot == false)
return;
for (auto& Entity : *CurrentPlayerList)
{
if (Entity.CanHit)
{
if (SDK::Cmd->csgoUserCmd.pBaseCmd->nClientTick >= SDK::LocalPawn->CSWeaponBase()->m_nNextPrimaryAttackTick())
{
SDK::Cmd->csgoUserCmd.pBaseCmd->pInButtonState->nValue |= IN_ATTACK;
SDK::Cmd->csgoUserCmd.pBaseCmd->pInButtonState->SetBits(BASE_BITS_BUTTONPB);
}
else
{
SDK::Cmd->csgoUserCmd.pBaseCmd->pInButtonState->nValue &= ~IN_ATTACK;
SDK::Cmd->csgoUserCmd.pBaseCmd->pInButtonState->SetBits(BASE_BITS_BUTTONPB);
}
}
}
}

View File

@@ -0,0 +1,284 @@
#pragma once
#include "qAngles.h"
#include "Utils/Memory.h"
#include "Utils/Defines.h"
#include "Utils/cVector.h"
enum ECommandButtons : std::uint64_t
{
IN_ATTACK = 1 << 0,
IN_JUMP = 1 << 1,
IN_DUCK = 1 << 2,
IN_FORWARD = 1 << 3,
IN_BACK = 1 << 4,
IN_USE = 1 << 5,
IN_LEFT = 1 << 7,
IN_RIGHT = 1 << 8,
IN_MOVELEFT = 1 << 9,
IN_MOVERIGHT = 1 << 10,
IN_SECOND_ATTACK = 1 << 11,
IN_RELOAD = 1 << 13,
IN_SPRINT = 1 << 16,
IN_JOYAUTOSPRINT = 1 << 17,
IN_SHOWSCORES = 1ULL << 33,
IN_ZOOM = 1ULL << 34,
IN_LOOKATWEAPON = 1ULL << 35
};
// compiled protobuf messages and looked at what bits are used in them
enum ESubtickMoveStepBits : std::uint32_t
{
MOVESTEP_BITS_BUTTON = 0x1U,
MOVESTEP_BITS_PRESSED = 0x2U,
MOVESTEP_BITS_WHEN = 0x4U,
MOVESTEP_BITS_ANALOG_FORWARD_DELTA = 0x8U,
MOVESTEP_BITS_ANALOG_LEFT_DELTA = 0x10U
};
enum EInputHistoryBits : std::uint32_t
{
INPUT_HISTORY_BITS_VIEWANGLES = 0x1U,
INPUT_HISTORY_BITS_SHOOTPOSITION = 0x2U,
INPUT_HISTORY_BITS_TARGETHEADPOSITIONCHECK = 0x4U,
INPUT_HISTORY_BITS_TARGETABSPOSITIONCHECK = 0x8U,
INPUT_HISTORY_BITS_TARGETANGCHECK = 0x10U,
INPUT_HISTORY_BITS_CL_INTERP = 0x20U,
INPUT_HISTORY_BITS_SV_INTERP0 = 0x40U,
INPUT_HISTORY_BITS_SV_INTERP1 = 0x80U,
INPUT_HISTORY_BITS_PLAYER_INTERP = 0x100U,
INPUT_HISTORY_BITS_RENDERTICKCOUNT = 0x200U,
INPUT_HISTORY_BITS_RENDERTICKFRACTION = 0x400U,
INPUT_HISTORY_BITS_PLAYERTICKCOUNT = 0x800U,
INPUT_HISTORY_BITS_PLAYERTICKFRACTION = 0x1000U,
INPUT_HISTORY_BITS_FRAMENUMBER = 0x2000U,
INPUT_HISTORY_BITS_TARGETENTINDEX = 0x4000U
};
enum EButtonStatePBBits : uint32_t
{
BUTTON_STATE_PB_BITS_BUTTONSTATE1 = 0x1U,
BUTTON_STATE_PB_BITS_BUTTONSTATE2 = 0x2U,
BUTTON_STATE_PB_BITS_BUTTONSTATE3 = 0x4U
};
enum EBaseCmdBits : std::uint32_t
{
BASE_BITS_MOVE_CRC = 0x1U,
BASE_BITS_BUTTONPB = 0x2U,
BASE_BITS_VIEWANGLES = 0x4U,
BASE_BITS_COMMAND_NUMBER = 0x8U,
BASE_BITS_CLIENT_TICK = 0x10U,
BASE_BITS_FORWARDMOVE = 0x20U,
BASE_BITS_LEFTMOVE = 0x40U,
BASE_BITS_UPMOVE = 0x80U,
BASE_BITS_IMPULSE = 0x100U,
BASE_BITS_WEAPON_SELECT = 0x200U,
BASE_BITS_RANDOM_SEED = 0x400U,
BASE_BITS_MOUSEDX = 0x800U,
BASE_BITS_MOUSEDY = 0x1000U,
BASE_BITS_CONSUMED_SERVER_ANGLE = 0x2000U,
BASE_BITS_CMD_FLAGS = 0x4000U,
BASE_BITS_ENTITY_HANDLE = 0x8000U
};
enum ECSGOUserCmdBits : std::uint32_t
{
CSGOUSERCMD_BITS_BASECMD = 0x1U,
CSGOUSERCMD_BITS_LEFTHAND = 0x2U,
CSGOUSERCMD_BITS_ATTACK3START = 0x4U,
CSGOUSERCMD_BITS_ATTACK1START = 0x8U,
CSGOUSERCMD_BITS_ATTACK2START = 0x10U
};
template <typename T>
struct RepeatedPtrField_t
{
struct Rep_t
{
int nAllocatedSize;
T* tElements[(2147483647 - 2 * sizeof(int)) / sizeof(void*)];
};
void* pArena;
int nCurrentSize;
int nTotalSize;
Rep_t* pRep;
};
class CBasePB
{
public:
MEM_PAD(0x8); // 0x0 VTABLE
std::uint32_t nHasBits; // 0x8
std::uint64_t nCachedBits; // 0xC
void SetBits(std::uint64_t nBits)
{
// @note: you don't need to check if the bits are already set as bitwise OR will not change the value if the bit is already set
nCachedBits |= nBits;
}
};
static_assert(sizeof(CBasePB) == 0x18);
class CMsgQAngle : public CBasePB
{
public:
QAngle_t angValue; // 0x18
};
static_assert(sizeof(CMsgQAngle) == 0x28);
class CMsgVector : public CBasePB
{
public:
Vector4D_t vecValue; // 0x18
};
static_assert(sizeof(CMsgVector) == 0x28);
class CCSGOInterpolationInfoPB : public CBasePB
{
public:
float flFraction; // 0x18
int nSrcTick; // 0x1C
int nDstTick; // 0x20
};
static_assert(sizeof(CCSGOInterpolationInfoPB) == 0x28);
class CCSGOInputHistoryEntryPB : public CBasePB
{
public:
CMsgQAngle* pViewAngles; // 0x18
CMsgVector* pShootPosition; // 0x20
CMsgVector* pTargetHeadPositionCheck; // 0x28
CMsgVector* pTargetAbsPositionCheck; // 0x30
CMsgQAngle* pTargetAngPositionCheck; // 0x38
CCSGOInterpolationInfoPB* cl_interp; // 0x40
CCSGOInterpolationInfoPB* sv_interp0; // 0x48
CCSGOInterpolationInfoPB* sv_interp1; // 0x50
CCSGOInterpolationInfoPB* player_interp; // 0x58
int nRenderTickCount; // 0x60
float flRenderTickFraction; // 0x64
int nPlayerTickCount; // 0x68
float flPlayerTickFraction; // 0x6C
int nFrameNumber; // 0x70
int nTargetEntIndex; // 0x74
};
static_assert(sizeof(CCSGOInputHistoryEntryPB) == 0x78);
struct CInButtonStatePB : CBasePB
{
std::uint64_t nValue;
std::uint64_t nValueChanged;
std::uint64_t nValueScroll;
};
static_assert(sizeof(CInButtonStatePB) == 0x30);
struct CSubtickMoveStep : CBasePB
{
public:
std::uint64_t nButton;
bool bPressed;
float flWhen;
float flAnalogForwardDelta;
float flAnalogLeftDelta;
};
static_assert(sizeof(CSubtickMoveStep) == 0x30);
class CBaseUserCmdPB : public CBasePB
{
public:
RepeatedPtrField_t<CSubtickMoveStep> subtickMovesField;
std::string* strMoveCrc;
CInButtonStatePB* pInButtonState;
CMsgQAngle* pViewAngles;
std::int32_t nLegacyCommandNumber;
std::int32_t nClientTick;
float flForwardMove;
float flSideMove;
float flUpMove;
std::int32_t nImpulse;
std::int32_t nWeaponSelect;
std::int32_t nRandomSeed;
std::int32_t nMousedX;
std::int32_t nMousedY;
std::uint32_t nConsumedServerAngleChanges;
std::int32_t nCmdFlags;
std::uint32_t nPawnEntityHandle;
int CalculateCmdCRCSize()
{
return M::CallVFunc<int, 7U>(this);
}
};
static_assert(sizeof(CBaseUserCmdPB) == 0x80);
class CCSGOUserCmdPB
{
public:
std::uint32_t nHasBits;
std::uint64_t nCachedSize;
RepeatedPtrField_t<CCSGOInputHistoryEntryPB> inputHistoryField;
CBaseUserCmdPB* pBaseCmd;
bool bLeftHandDesired;
std::int32_t nAttack3StartHistoryIndex;
std::int32_t nAttack1StartHistoryIndex;
std::int32_t nAttack2StartHistoryIndex;
// @note: this function is used to check if the bits are set and set them if they are not
void CheckAndSetBits(std::uint32_t nBits)
{
if (!(nHasBits & nBits))
nHasBits |= nBits;
}
};
static_assert(sizeof(CCSGOUserCmdPB) == 0x40);
struct CInButtonState
{
public:
MEM_PAD(0x8) // 0x0 VTABLE
std::uint64_t nValue; // 0x8
std::uint64_t nValueChanged; // 0x10
std::uint64_t nValueScroll; // 0x18
};
static_assert(sizeof(CInButtonState) == 0x20);
class CUserCmd
{
public:
MEM_PAD(0x8); // 0x0 VTABLE
MEM_PAD(0x10); // TODO: find out what this is, added 14.08.2024
CCSGOUserCmdPB csgoUserCmd; // 0x18
CInButtonState nButtons; // 0x58
MEM_PAD(0x20); // 0x78
CCSGOInputHistoryEntryPB* GetInputHistoryEntry(int nIndex)
{
if (nIndex >= csgoUserCmd.inputHistoryField.pRep->nAllocatedSize || nIndex >= csgoUserCmd.inputHistoryField.nCurrentSize)
return nullptr;
return csgoUserCmd.inputHistoryField.pRep->tElements[nIndex];
}
void SetSubTickAngle(const QAngle_t& angView)
{
for (int i = 0; i < this->csgoUserCmd.inputHistoryField.pRep->nAllocatedSize; i++)
{
CCSGOInputHistoryEntryPB* pInputEntry = this->GetInputHistoryEntry(i);
if (!pInputEntry || !pInputEntry->pViewAngles)
continue;
pInputEntry->pViewAngles->angValue = angView;
pInputEntry->SetBits(EInputHistoryBits::INPUT_HISTORY_BITS_VIEWANGLES);
}
}
};
static_assert(sizeof(CUserCmd) == 0x98);

View File

@@ -0,0 +1,35 @@
#pragma once
#define M_PI 3.14159265358979323846
#define _CS_INTERNAL_CONCATENATE(LEFT, RIGHT) LEFT##RIGHT
#define CS_CONCATENATE(LEFT, RIGHT) _CS_INTERNAL_CONCATENATE(LEFT, RIGHT)
#define MEM_PAD(SIZE) \
private: \
char CS_CONCATENATE(pad_0, __COUNTER__)[SIZE]; \
public:
#define MAX_PATH 260
#define SCHEMASYSTEM_TYPE_SCOPES_OFFSET 0x188
#define SCHEMASYSTEMTYPESCOPE_OFF1 0x3F8
#define SCHEMASYSTEMTYPESCOPE_OFF2 0x8
#define _NUMBER_MAX_BASE 36;
#define CLIENT_DLL (L"client.dll")
#define SCENESYSTEM_DLL (L"scenesystem.dll")
#define ENGINE2_DLL (L"engine2.dll")
#define GAME_RESOURCE_SERVICE_CLIENT ("GameResourceServiceClientV00")
#define SOURCE2_ENGINE_TO_CLIENT ("Source2EngineToClient00")
#define SCHEMASYSTEM_DLL L"schemasystem.dll"
#define SCHEMA_SYSTEM "SchemaSystem_00"
#define TIER0_DLL (L"tier0.dll")
#define DBGHELP_DLL (L"dbghelp.dll")

View File

@@ -0,0 +1,26 @@
#pragma once
using FNV1A_t = std::uint64_t;
namespace FNV1A
{
using FNV1A_t = std::uint64_t;
constexpr FNV1A_t ullBasis = 0xCBF29CE484222325ULL;
constexpr FNV1A_t ullPrime = 0x100000001B3ULL;
consteval FNV1A_t HashConst(const char* szString, const FNV1A_t uKey = ullBasis) noexcept
{
return (szString[0] == '\0') ? uKey : HashConst(&szString[1], (uKey ^ static_cast<FNV1A_t>(szString[0])) * ullPrime);
}
inline FNV1A_t Hash(const char* szString, FNV1A_t uKey = ullBasis) noexcept
{
while (*szString)
{
uKey ^= static_cast<FNV1A_t>(*szString++);
uKey *= ullPrime;
}
return uKey;
}
}

View File

@@ -0,0 +1,196 @@
#pragma once
#include <cstdint>
#include <limits>
#include <cstdint>
#include "Defines.h"
class CUtlMemoryPool
{
public:
int Count() const
{
return nBlocksAllocated;
}
int PeakCount() const
{
return nPeakAlloc;
}
int BlockSize() const
{
return nBlockSize;
}
protected:
class CBlob
{
public:
CBlob* pPrev;
CBlob* pNext;
int nNumBytes;
char Data[1];
char Padding[3];
};
int nBlockSize;
int nBlocksPerBlob;
int nGrowMode;
int nBlocksAllocated;
int nPeakAlloc;
unsigned short nAlignment;
unsigned short nNumBlobs;
void* pHeadOfFreeList;
void* pAllocOwner;
CBlob BlobHead;
};
using UtlTSHashHandle_t = std::uintptr_t;
inline unsigned HashIntConventional(const int n)
{
unsigned hash = 0xAAAAAAAA + (n & 0xFF);
hash = (hash << 5) + hash + ((n >> 8) & 0xFF);
hash = (hash << 5) + hash + ((n >> 16) & 0xFF);
hash = (hash << 5) + hash + ((n >> 24) & 0xFF);
return hash;
}
template <int nBucketCount, class tKey = std::uintptr_t>
class CUtlTSHashGenericHash
{
public:
static int Hash(const tKey& Key, int nBucketMask)
{
int nHash = HashIntConventional(std::uintptr_t(Key));
if (nBucketCount <= UINT16_MAX)
{
nHash ^= (nHash >> 16);
}
if (nBucketCount <= UINT8_MAX)
{
nHash ^= (nHash >> 8);
}
return (nHash & nBucketMask);
}
static bool Compare(const tKey& lhs, const tKey& rhs)
{
return lhs == rhs;
}
};
template <class tElement, int nBucketCount, class tKey = std::uintptr_t, class tHashFuncs = CUtlTSHashGenericHash<nBucketCount, tKey>, int nAlignment = 0>
class CUtlTSHash
{
static constexpr int nBucketMask = nBucketCount - 1;
public:
static constexpr UtlTSHashHandle_t InvalidHandle()
{
return static_cast<UtlTSHashHandle_t>(0);
}
UtlTSHashHandle_t Find(tKey uiKey)
{
int iBucket = tHashFuncs::Hash(uiKey, nBucketCount);
const HashBucket_t& hashBucket = aBuckets[iBucket];
const UtlTSHashHandle_t hHash = Find(uiKey, hashBucket.pFirst, nullptr);
return hHash ? hHash : Find(uiKey, hashBucket.pFirstUncommited, hashBucket.pFirst);
}
int Count() const
{
return EntryMemory.Count();
}
int GetElements(int nFirstElement, int nCount, UtlTSHashHandle_t* pHandles) const
{
int nIndex = 0;
for (int nBucketIndex = 0; nBucketIndex < nBucketCount; nBucketIndex++)
{
const HashBucket_t& hashBucket = aBuckets[nBucketIndex];
HashFixedData_t* pElement = hashBucket.pFirstUncommited;
for (; pElement; pElement = pElement->pNext)
{
if (--nFirstElement >= 0)
continue;
pHandles[nIndex++] = reinterpret_cast<UtlTSHashHandle_t>(pElement);
if (nIndex >= nCount)
return nIndex;
}
}
return nIndex;
}
tElement Element(UtlTSHashHandle_t hHash)
{
return ((HashFixedData_t*)(hHash))->Data;
}
const tElement& Element(UtlTSHashHandle_t hHash) const
{
return reinterpret_cast<HashFixedData_t*>(hHash)->Data;
}
tElement& operator[](UtlTSHashHandle_t hHash)
{
return reinterpret_cast<HashFixedData_t*>(hHash)->Data;
}
const tElement& operator[](UtlTSHashHandle_t hHash) const
{
return reinterpret_cast<HashFixedData_t*>(hHash)->Data;
}
tKey GetID(UtlTSHashHandle_t hHash) const
{
return reinterpret_cast<HashFixedData_t*>(hHash)->uiKey;
}
private:
template <typename tData>
struct HashFixedDataInternal_t
{
tKey uiKey;
HashFixedDataInternal_t<tData>* pNext;
tData Data;
};
using HashFixedData_t = HashFixedDataInternal_t<tElement>;
struct HashBucket_t
{
private:
[[maybe_unused]] std::byte pad0[0x18];
public:
HashFixedData_t* pFirst;
HashFixedData_t* pFirstUncommited;
};
UtlTSHashHandle_t Find(tKey uiKey, HashFixedData_t* pFirstElement, HashFixedData_t* pLastElement)
{
for (HashFixedData_t* pElement = pFirstElement; pElement != pLastElement; pElement = pElement->pNext)
{
if (tHashFuncs::Compare(pElement->uiKey, uiKey))
return reinterpret_cast<UtlTSHashHandle_t>(pElement);
}
return InvalidHandle();
}
CUtlMemoryPool EntryMemory;
MEM_PAD(0x40);
HashBucket_t aBuckets[nBucketCount];
bool bNeedsCommit;
};

View File

@@ -0,0 +1,73 @@
#pragma once
#include "Memory.h"
using InstantiateInterfaceFn_t = void* (*)();
class ISchemaSystem;
class IGameResourceService;
class IEngineClient;
class IEngineCVar;
class Tracing;
class IMemAlloc;
class CInterfaceRegister
{
public:
InstantiateInterfaceFn_t fnCreate;
const char* szName;
CInterfaceRegister* pNext;
};
namespace I
{
static const CInterfaceRegister* GetRegisterList(const wchar_t* wszModuleName)
{
void* hModule = M::GetModuleBaseHandle(wszModuleName);
if (hModule == nullptr)
return nullptr;
std::uint8_t* pCreateInterface = reinterpret_cast<std::uint8_t*>(M::GetExportAddress(hModule, "CreateInterface"));
if (pCreateInterface == nullptr)
{
return nullptr;
}
return *reinterpret_cast<CInterfaceRegister**>(M::ResolveRelativeAddress(pCreateInterface, 0x3, 0x7));
}
template <typename T = void*>
T* Capture(const CInterfaceRegister* pModuleRegister, const char* szInterfaceName)
{
std::size_t nInterfaceNameLength = std::strlen(szInterfaceName);
for (const CInterfaceRegister* pRegister = pModuleRegister; pRegister != nullptr; pRegister = pRegister->pNext)
{
std::size_t nRegisterNameLength = std::strlen(pRegister->szName);
if (std::strncmp(szInterfaceName, pRegister->szName, nInterfaceNameLength) == 0 &&
(nRegisterNameLength == nInterfaceNameLength ||
std::strtol(pRegister->szName + nInterfaceNameLength, nullptr, 10) > 0))
{
void* pInterface = pRegister->fnCreate();
return static_cast<T*>(pInterface);
}
}
return nullptr;
}
inline ISchemaSystem* SchemaSystem = nullptr;
inline Tracing* Trace = nullptr;
inline IGameResourceService* GameResourceService = nullptr;
inline IEngineClient* Engine = nullptr;
inline IEngineCVar* Cvar = nullptr;
inline IMemAlloc* MemAlloc = nullptr;
}

View File

@@ -0,0 +1,200 @@
#pragma once
#include "Windows.h"
#include "string"
#include "vector"
#include "cVector.h"
#include "../qAngles.h"
#include "Defines.h"
#ifndef DEG2RAD
#define DEG2RAD(x) ((x) * (M_PI / 180.0f))
#endif
class CUtlBuffer;
namespace M
{
inline void* GetModuleBaseHandle(const wchar_t* wszModuleName)
{
if (wszModuleName == nullptr)
return GetModuleHandle(nullptr);
HMODULE hModule = GetModuleHandleW(wszModuleName);
return hModule;
}
template <typename C>
inline constexpr int StringCompare(const C* tszLeft, const C* tszRight)
{
if constexpr (std::is_same_v<C, char>)
{
return std::strcmp(tszLeft, tszRight);
}
else if constexpr (std::is_same_v<C, wchar_t>)
{
return std::wcscmp(tszLeft, tszRight);
}
}
inline void* GetExportAddress(const void* hModuleBase, const char* szProcedureName)
{
const auto pBaseAddress = static_cast<const std::uint8_t*>(hModuleBase);
const auto pIDH = static_cast<const IMAGE_DOS_HEADER*>(hModuleBase);
if (pIDH->e_magic != IMAGE_DOS_SIGNATURE)
return nullptr;
const auto pINH = reinterpret_cast<const IMAGE_NT_HEADERS64*>(pBaseAddress + pIDH->e_lfanew);
if (pINH->Signature != IMAGE_NT_SIGNATURE)
return nullptr;
const IMAGE_OPTIONAL_HEADER64* pIOH = &pINH->OptionalHeader;
const std::uintptr_t nExportDirectorySize = pIOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
const std::uintptr_t uExportDirectoryAddress = pIOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
if (nExportDirectorySize == 0U || uExportDirectoryAddress == 0U)
{
return nullptr;
}
const auto pIED = reinterpret_cast<const IMAGE_EXPORT_DIRECTORY*>(pBaseAddress + uExportDirectoryAddress);
const auto pNamesRVA = reinterpret_cast<const std::uint32_t*>(pBaseAddress + pIED->AddressOfNames);
const auto pNameOrdinalsRVA = reinterpret_cast<const std::uint16_t*>(pBaseAddress + pIED->AddressOfNameOrdinals);
const auto pFunctionsRVA = reinterpret_cast<const std::uint32_t*>(pBaseAddress + pIED->AddressOfFunctions);
// Perform binary search to find the export by name
std::size_t nRight = pIED->NumberOfNames, nLeft = 0U;
while (nRight != nLeft)
{
// Avoid INT_MAX/2 overflow
const std::size_t uMiddle = nLeft + ((nRight - nLeft) >> 1U);
const int iResult = StringCompare(szProcedureName, reinterpret_cast<const char*>(pBaseAddress + pNamesRVA[uMiddle]));
if (iResult == 0)
{
const std::uint32_t uFunctionRVA = pFunctionsRVA[pNameOrdinalsRVA[uMiddle]];
// Check if it's a forwarded export
if (uFunctionRVA >= uExportDirectoryAddress && uFunctionRVA - uExportDirectoryAddress < nExportDirectorySize)
{
// Forwarded exports are not supported
break;
}
return const_cast<std::uint8_t*>(pBaseAddress) + uFunctionRVA;
}
if (iResult > 0)
nLeft = uMiddle + 1;
else
nRight = uMiddle;
}
return nullptr;
}
inline std::uint8_t* ResolveRelativeAddress(std::uint8_t* nAddressBytes, std::uint32_t nRVAOffset, std::uint32_t nRIPOffset)
{
std::uint32_t nRVA = *reinterpret_cast<std::uint32_t*>(nAddressBytes + nRVAOffset);
std::uint64_t nRIP = reinterpret_cast<std::uint64_t>(nAddressBytes) + nRIPOffset;
return reinterpret_cast<std::uint8_t*>(nRVA + nRIP);
}
template <typename T, std::size_t nIndex, class CBaseClass, typename... Args_t>
static inline T CallVFunc(CBaseClass* thisptr, Args_t... argList)
{
using VirtualFn_t = T(__thiscall*)(const void*, decltype(argList)...);
return (*reinterpret_cast<VirtualFn_t* const*>(reinterpret_cast<std::uintptr_t>(thisptr)))[nIndex](thisptr, argList...);
}
inline std::vector<int> PatternToBytes(const char* pattern) {
std::vector<int> bytes;
const char* current = pattern;
while (*current) {
if (*current == '?') {
bytes.push_back(-1); // Wildcard
current++;
if (*current == '?') current++; // Skip second '?'
}
else {
bytes.push_back(static_cast<int>(std::strtoul(current, nullptr, 16)));
current += 2;
}
if (*current == ' ') current++; // Skip spaces
}
return bytes;
}
inline uintptr_t FindPattern(const wchar_t* moduleName, const char* pattern)
{
HMODULE hModule = GetModuleHandleW(moduleName);
if (!hModule) return 0;
std::uint8_t* moduleBase = reinterpret_cast<std::uint8_t*>(hModule);
PIMAGE_NT_HEADERS ntHeaders = reinterpret_cast<PIMAGE_NT_HEADERS>(moduleBase + reinterpret_cast<PIMAGE_DOS_HEADER>(moduleBase)->e_lfanew);
std::size_t moduleSize = ntHeaders->OptionalHeader.SizeOfImage;
std::vector<int> patternBytes = PatternToBytes(pattern);
std::size_t patternLength = patternBytes.size();
for (std::size_t i = 0; i <= moduleSize - patternLength; i++) {
bool found = true;
for (std::size_t j = 0; j < patternLength; j++) {
if (patternBytes[j] != -1 && patternBytes[j] != moduleBase[i + j]) {
found = false;
break;
}
}
if (found)
return reinterpret_cast<uintptr_t>(moduleBase + i);
}
return 0;
}
template <typename T = uintptr_t>
T GetAbsoluteAddress(T pRelativeAddress, int nPreOffset = 0x0, int nPostOffset = 0x0) {
std::int32_t relativeOffset = *reinterpret_cast<std::int32_t*>(reinterpret_cast<std::uint8_t*>(pRelativeAddress) + nPreOffset);
return pRelativeAddress + relativeOffset + sizeof(std::int32_t) + nPreOffset + nPostOffset;
}
inline void** CopyVirtualTable(void** Original)
{
constexpr int Entries = 8192 / sizeof(void*);
void** NewVTable = new void* [Entries];
for (int i = 0; i < Entries; ++i)
NewVTable[i] = Original[i];
return NewVTable;
}
inline Vector_t AngleToDirection(const QAngle_t& Angles)
{
Vector_t Direction;
float Pitch = DEG2RAD(Angles.x);
float Yaw = DEG2RAD(Angles.y);
Direction.x = cos(Pitch) * cos(Yaw);
Direction.y = cos(Pitch) * sin(Yaw);
Direction.z = -sin(Pitch);
return Direction;
}
inline void(__fastcall* fnUtlBufferInit)(CUtlBuffer*, int, int, int);
inline void(__fastcall* fnUtlBufferPutString)(CUtlBuffer*, const char*);
inline void(__fastcall* fnUtlBufferEnsureCapacity)(CUtlBuffer*, int);
}

View File

@@ -0,0 +1,113 @@
#pragma once
#include <type_traits>
namespace detail {
extern "C" void* _spoofer_stub();
template <typename Ret, typename... Args>
static auto shellcode_stub_helper(
const void* shell,
Args... args
) -> Ret {
auto fn = (Ret(*)(Args...))(shell);
return fn(args...);
}
template <std::size_t Argc, typename>
struct argument_remapper {
// At least 5 params
template<
typename Ret,
typename First,
typename Second,
typename Third,
typename Fourth,
typename... Pack
>
static auto do_call(
const void* shell,
void* shell_param,
First first,
Second second,
Third third,
Fourth fourth,
Pack... pack
) -> Ret {
return shellcode_stub_helper<
Ret,
First,
Second,
Third,
Fourth,
void*,
void*,
Pack...
>(
shell,
first,
second,
third,
fourth,
shell_param,
nullptr,
pack...
);
}
};
template <std::size_t Argc>
struct argument_remapper<Argc, std::enable_if_t<Argc <= 4>> {
// 4 or less params
template<
typename Ret,
typename First = void*,
typename Second = void*,
typename Third = void*,
typename Fourth = void*
>
static auto do_call(
const void* shell,
void* shell_param,
First first = First{},
Second second = Second{},
Third third = Third{},
Fourth fourth = Fourth{}
) -> Ret {
return shellcode_stub_helper<
Ret,
First,
Second,
Third,
Fourth,
void*,
void*
>(
shell,
first,
second,
third,
fourth,
shell_param,
nullptr
);
}
};
}
template <typename result, typename... arguments>
static auto FakeReturnAddress(
const void* trampoline,
result(*fn)(arguments...),
arguments... args
) -> result {
struct shell_params {
const void* trampoline;
void* function;
void* register_; // originally rbx, currently rdx
};
shell_params p = { trampoline, reinterpret_cast<void*>(fn) };
using mapper = detail::argument_remapper<sizeof...(arguments), void>;
return mapper::template do_call<result, arguments...>((const void*)&detail::_spoofer_stub, &p, args...);
}

View File

@@ -0,0 +1,400 @@
#pragma once
// used: [stl] numeric_limits
#include <limits>
// used: [crt] isfinite, fmodf, sqrtf
#include <cmath>
// forward declarations
struct QAngle_t;
struct Matrix3x4_t;
// @source: master/public/mathlib/vector.h
struct Vector2D_t
{
constexpr Vector2D_t(const float x = 0.0f, const float y = 0.0f) :
x(x), y(y) { }
[[nodiscard]] bool IsZero() const
{
// @note: to make this implementation right, we should use fpclassify here, but game aren't doing same, probably it's better to keep this same, just ensure that it will be compiled same
return (this->x == 0.0f && this->y == 0.0f);
}
float DistanceTo(const Vector2D_t& other) const
{
float dx = x - other.x;
float dy = y - other.y;
return sqrt(dx * dx + dy * dy);
}
float x = 0.0f, y = 0.0f;
};
struct Vector_t
{
constexpr Vector_t(const float x = 0.0f, const float y = 0.0f, const float z = 0.0f) :
x(x), y(y), z(z) { }
constexpr Vector_t(const float* arrVector) :
x(arrVector[0]), y(arrVector[1]), z(arrVector[2]) { }
constexpr Vector_t(const Vector2D_t& vecBase2D) :
x(vecBase2D.x), y(vecBase2D.y) { }
#pragma region vector_array_operators
[[nodiscard]] float& operator[](const int nIndex)
{
return reinterpret_cast<float*>(this)[nIndex];
}
[[nodiscard]] const float& operator[](const int nIndex) const
{
return reinterpret_cast<const float*>(this)[nIndex];
}
#pragma endregion
#pragma region vector_relational_operators
bool operator==(const Vector_t& vecBase) const
{
return this->IsEqual(vecBase);
}
bool operator!=(const Vector_t& vecBase) const
{
return !this->IsEqual(vecBase);
}
#pragma endregion
#pragma region vector_assignment_operators
constexpr Vector_t& operator=(const Vector_t& vecBase)
{
this->x = vecBase.x;
this->y = vecBase.y;
this->z = vecBase.z;
return *this;
}
constexpr Vector_t& operator=(const Vector2D_t& vecBase2D)
{
this->x = vecBase2D.x;
this->y = vecBase2D.y;
this->z = 0.0f;
return *this;
}
#pragma endregion
#pragma region vector_arithmetic_assignment_operators
constexpr Vector_t& operator+=(const Vector_t& vecBase)
{
this->x += vecBase.x;
this->y += vecBase.y;
this->z += vecBase.z;
return *this;
}
constexpr Vector_t& operator-=(const Vector_t& vecBase)
{
this->x -= vecBase.x;
this->y -= vecBase.y;
this->z -= vecBase.z;
return *this;
}
constexpr Vector_t& operator*=(const Vector_t& vecBase)
{
this->x *= vecBase.x;
this->y *= vecBase.y;
this->z *= vecBase.z;
return *this;
}
constexpr Vector_t& operator/=(const Vector_t& vecBase)
{
this->x /= vecBase.x;
this->y /= vecBase.y;
this->z /= vecBase.z;
return *this;
}
constexpr Vector_t& operator+=(const float flAdd)
{
this->x += flAdd;
this->y += flAdd;
this->z += flAdd;
return *this;
}
constexpr Vector_t& operator-=(const float flSubtract)
{
this->x -= flSubtract;
this->y -= flSubtract;
this->z -= flSubtract;
return *this;
}
constexpr Vector_t& operator*=(const float flMultiply)
{
this->x *= flMultiply;
this->y *= flMultiply;
this->z *= flMultiply;
return *this;
}
constexpr Vector_t& operator/=(const float flDivide)
{
this->x /= flDivide;
this->y /= flDivide;
this->z /= flDivide;
return *this;
}
#pragma endregion
#pragma region vector_arithmetic_unary_operators
constexpr Vector_t& operator-()
{
this->x = -this->x;
this->y = -this->y;
this->z = -this->z;
return *this;
}
constexpr Vector_t operator-() const
{
return { -this->x, -this->y, -this->z };
}
#pragma endregion
#pragma region vector_arithmetic_ternary_operators
Vector_t operator+(const Vector_t& vecAdd) const
{
return { this->x + vecAdd.x, this->y + vecAdd.y, this->z + vecAdd.z };
}
Vector_t operator-(const Vector_t& vecSubtract) const
{
return { this->x - vecSubtract.x, this->y - vecSubtract.y, this->z - vecSubtract.z };
}
Vector_t operator*(const Vector_t& vecMultiply) const
{
return { this->x * vecMultiply.x, this->y * vecMultiply.y, this->z * vecMultiply.z };
}
Vector_t operator/(const Vector_t& vecDivide) const
{
return { this->x / vecDivide.x, this->y / vecDivide.y, this->z / vecDivide.z };
}
Vector_t operator+(const float flAdd) const
{
return { this->x + flAdd, this->y + flAdd, this->z + flAdd };
}
Vector_t operator-(const float flSubtract) const
{
return { this->x - flSubtract, this->y - flSubtract, this->z - flSubtract };
}
Vector_t operator*(const float flMultiply) const
{
return { this->x * flMultiply, this->y * flMultiply, this->z * flMultiply };
}
Vector_t operator/(const float flDivide) const
{
return { this->x / flDivide, this->y / flDivide, this->z / flDivide };
}
#pragma endregion
/// @returns: true if each component of the vector is finite, false otherwise
[[nodiscard]] bool IsValid() const
{
return std::isfinite(this->x) && std::isfinite(this->y) && std::isfinite(this->z);
}
constexpr void Invalidate()
{
this->x = this->y = this->z = std::numeric_limits<float>::infinity();
}
/// @returns: true if each component of the vector equals to another, false otherwise
[[nodiscard]] bool IsEqual(const Vector_t& vecEqual, const float flErrorMargin = std::numeric_limits<float>::epsilon()) const
{
return (std::fabsf(this->x - vecEqual.x) < flErrorMargin && std::fabsf(this->y - vecEqual.y) < flErrorMargin && std::fabsf(this->z - vecEqual.z) < flErrorMargin);
}
/// @returns: true if each component of the vector equals to zero, false otherwise
[[nodiscard]] bool IsZero() const
{
// @note: to make this implementation right, we should use fpclassify here, but game aren't doing same, probably it's better to keep this same, just ensure that it will be compiled same
return (this->x == 0.0f && this->y == 0.0f && this->z == 0.0f);
}
[[nodiscard]] float Length() const
{
return std::sqrtf(this->LengthSqr());
}
[[nodiscard]] constexpr float LengthSqr() const
{
return DotProduct(*this);
}
[[nodiscard]] float Length2D() const
{
return std::sqrtf(this->Length2DSqr());
}
[[nodiscard]] constexpr float Length2DSqr() const
{
return (this->x * this->x + this->y * this->y);
}
[[nodiscard]] float DistTo(const Vector_t& vecEnd) const
{
return (*this - vecEnd).Length();
}
[[nodiscard]] constexpr float DistToSqr(const Vector_t& vecEnd) const
{
return (*this - vecEnd).LengthSqr();
}
/// normalize magnitude of each component of the vector
/// @returns: length of the vector
float NormalizeInPlace()
{
const float flLength = this->Length();
const float flRadius = 1.0f / (flLength + std::numeric_limits<float>::epsilon());
this->x *= flRadius;
this->y *= flRadius;
this->z *= flRadius;
return flLength;
}
/// normalize magnitude of each component of the vector
/// @returns: copy of the vector with normalized components
[[nodiscard]] Vector_t Normalized() const
{
Vector_t vecOut = *this;
vecOut.NormalizeInPlace();
return vecOut;
}
[[nodiscard]] constexpr float DotProduct(const Vector_t& vecDot) const
{
return (this->x * vecDot.x + this->y * vecDot.y + this->z * vecDot.z);
}
[[nodiscard]] constexpr Vector_t CrossProduct(const Vector_t& vecCross) const
{
return { this->y * vecCross.z - this->z * vecCross.y, this->z * vecCross.x - this->x * vecCross.z, this->x * vecCross.y - this->y * vecCross.x };
}
/// @returns: transformed vector by given transformation matrix
[[nodiscard]] Vector_t Transform(const Matrix3x4_t& matTransform) const;
[[nodiscard]] Vector2D_t ToVector2D() const
{
return { this->x, this->y };
}
/// convert forward direction vector to other direction vectors
/// @param[out] pvecRight [optional] output for converted right vector
/// @param[out] pvecUp [optional] output for converted up vector
void ToDirections(Vector_t* pvecRight, Vector_t* pvecUp) const
{
if (std::fabsf(this->x) < 1e-6f && std::fabsf(this->y) < 1e-6f)
{
// pitch 90 degrees up/down from identity
if (pvecRight != nullptr)
{
pvecRight->x = 0.0f;
pvecRight->y = -1.0f;
pvecRight->z = 0.0f;
}
if (pvecUp != nullptr)
{
pvecUp->x = -this->z;
pvecUp->y = 0.0f;
pvecUp->z = 0.0f;
}
}
else
{
if (pvecRight != nullptr)
{
pvecRight->x = this->y;
pvecRight->y = -this->x;
pvecRight->z = 0.0f;
pvecRight->NormalizeInPlace();
}
if (pvecUp != nullptr)
{
pvecUp->x = (-this->x) * this->z;
pvecUp->y = -(this->y * this->z);
pvecUp->z = this->y * this->y - (-this->x) * this->x;
pvecUp->NormalizeInPlace();
}
}
}
/// @returns: 2D angles converted from direction vector
[[nodiscard]] QAngle_t ToAngles() const;
/// @returns: matrix converted from forward direction vector
[[nodiscard]] Matrix3x4_t ToMatrix() const;
float x = 0.0f, y = 0.0f, z = 0.0f;
};
struct Vector4D_t
{
constexpr Vector4D_t(const float x = 0.0f, const float y = 0.0f, const float z = 0.0f, const float w = 0.0f) :
x(x), y(y), z(z), w(w) { }
float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
};
struct alignas(16) VectorAligned_t : Vector_t
{
VectorAligned_t() = default;
explicit VectorAligned_t(const Vector_t& vecBase)
{
this->x = vecBase.x;
this->y = vecBase.y;
this->z = vecBase.z;
this->w = 0.0f;
}
constexpr VectorAligned_t& operator=(const Vector_t& vecBase)
{
this->x = vecBase.x;
this->y = vecBase.y;
this->z = vecBase.z;
this->w = 0.0f;
return *this;
}
float w = 0.0f;
};
static_assert(alignof(VectorAligned_t) == 16);

View File

@@ -0,0 +1,32 @@
PUBLIC _spoofer_stub
option casemap :none
; if the line is labelled as MODIFY you need to modify the register it reads or writes to
; valid registers include: rbx, rbp+0x0, rdi, rsi, r12, r13+0x0, r14, r15
_TEXT SEGMENT
_spoofer_stub PROC
pop r11 ; poping without setting up stack frame, r11 is the return address (the one in our code)
add rsp, 8 ; skipping callee reserved space
mov rax, [rsp + 24] ; dereference shell_param
mov r10, [rax] ; load shell_param.trampoline
mov [rsp], r10 ; store address of trampoline as return address
mov r10, [rax + 8] ; load shell_param.function
mov [rax + 8], r11 ; store the original return address in shell_param.function
mov [rax + 16], rdi ; preserve register in shell_param.register_ | MODIFY
lea rdi, fixup ; load fixup address in register | MODIFY
mov [rax], rdi ; store address of fixup label in shell_param.trampoline | MODIFY
mov rdi, rax ; preserve address of shell_param in register | MODIFY
jmp r10 ; call shell_param.function
fixup:
sub rsp, 16
mov rcx, rdi ; restore address of shell_param | MODIFY
mov rdi, [rcx + 16] ; restore register from shell_param.register_ | MODIFY
jmp QWORD PTR [rcx + 8] ; jmp to the original return address
_spoofer_stub ENDP
_TEXT ENDS
END

View File

@@ -0,0 +1,29 @@
#pragma once
#include "Utils/cVector.h"
#include "Offsets.h"
#include "ImGui/imgui.h"
class ScreenProjection
{
public:
BOOL WorldToScreen(const Vector_t& Pos, Vector2D_t& ToPos) const
{
float(*ViewMatrix)[4][4] = reinterpret_cast<float(*)[4][4]>(Offsets->GameData.dwViewMatrix);
const float w = (*ViewMatrix)[3][0] * Pos.x + (*ViewMatrix)[3][1] * Pos.y + (*ViewMatrix)[3][2] * Pos.z + (*ViewMatrix)[3][3];
if (w <= 0.01)
return FALSE;
const float invW = 1.0f / w;
const float SightX = ImGui::GetIO().DisplaySize.x * 0.5f;
const float SightY = ImGui::GetIO().DisplaySize.y * 0.5f;
ToPos.x = SightX + (((*ViewMatrix)[0][0] * Pos.x + (*ViewMatrix)[0][1] * Pos.y + (*ViewMatrix)[0][2] * Pos.z + (*ViewMatrix)[0][3]) * invW * SightX);
ToPos.y = SightY - (((*ViewMatrix)[1][0] * Pos.x + (*ViewMatrix)[1][1] * Pos.y + (*ViewMatrix)[1][2] * Pos.z + (*ViewMatrix)[1][3]) * invW * SightY);
return TRUE;
}
};
inline ScreenProjection View;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
#pragma once
#include "EntityHandle.h"
#include "Utils/Memory.h"
#include "Utils/Defines.h"
#include "Entity.h"
#include "CCSGOInput.h"
#define MAX_ENTITIES_IN_LIST 512
#define MAX_ENTITY_LISTS 64
#define MAX_TOTAL_ENTITIES MAX_ENTITIES_IN_LIST* MAX_ENTITY_LISTS
class C_BaseEntity;
class CGameEntitySystem
{
public:
template <typename T = C_BaseEntity>
T* Get(int nIndex)
{
return reinterpret_cast<T*>(this->GetEntityByIndex(nIndex));
}
template <typename T = C_BaseEntity>
T* Get(const CBaseHandle hHandle)
{
if (!hHandle.IsValid())
return nullptr;
return reinterpret_cast<T*>(this->GetEntityByIndex(hHandle.GetEntryIndex()));
}
int GetHighestEntityIndex()
{
return *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(this) + 0x1510);
}
private:
void* GetEntityByIndex(int nIndex)
{
using fnGetBaseEntity = void* (__thiscall*)(void*, int);
static auto GetBaseEntity = reinterpret_cast<fnGetBaseEntity>(M::FindPattern(CLIENT_DLL, "81 FA ? ? ? ? 77 ? 8B C2 C1 F8 ? 83 F8 ? 77 ? 48 98 48 8B 4C C1 ? 48 85 C9 74 ? 8B C2 25 ? ? ? ? 48 6B C0 ? 48 03 C8 74 ? 8B 41 ? 25 ? ? ? ? 3B C2 75 ? 48 8B 01"));
return GetBaseEntity(this, nIndex);
}
};
namespace SDK
{
inline CCSPlayerController* LocalController = nullptr;
inline C_CSPlayerPawn* LocalPawn = nullptr;
inline CUserCmd* Cmd = nullptr;
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include <windows.h>
#include "detours.h"
#pragma comment( lib, "detours.lib" )
PVOID SetDetour( PVOID& Target, PVOID Handler );
BOOL RemoveDetour( PVOID* ppTarget, PVOID Handler );

View File

@@ -0,0 +1,626 @@
//////////////////////////////////////////////////////////////////////////////
//
// Core Detours Functionality (detours.h of detours.lib)
//
// Microsoft Research Detours Package, Version 3.0 Build_316.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#pragma once
#ifndef _DETOURS_H_
#define _DETOURS_H_
#define DETOURS_VERSION 30000 // 3.00.00
//////////////////////////////////////////////////////////////////////////////
//
#if (_MSC_VER < 1299)
typedef LONG LONG_PTR;
typedef ULONG ULONG_PTR;
#endif
#ifndef __in_z
#define __in_z
#endif
//////////////////////////////////////////////////////////////////////////////
//
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID
{
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[ 8 ];
} GUID;
#ifdef INITGUID
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
const GUID name \
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#else
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
const GUID name
#endif // INITGUID
#endif // !GUID_DEFINED
#if defined(__cplusplus)
#ifndef _REFGUID_DEFINED
#define _REFGUID_DEFINED
#define REFGUID const GUID &
#endif // !_REFGUID_DEFINED
#else // !__cplusplus
#ifndef _REFGUID_DEFINED
#define _REFGUID_DEFINED
#define REFGUID const GUID * const
#endif // !_REFGUID_DEFINED
#endif // !__cplusplus
//
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/////////////////////////////////////////////////// Instruction Target Macros.
//
#define DETOUR_INSTRUCTION_TARGET_NONE ((PVOID)0)
#define DETOUR_INSTRUCTION_TARGET_DYNAMIC ((PVOID)(LONG_PTR)-1)
#define DETOUR_SECTION_HEADER_SIGNATURE 0x00727444 // "Dtr\0"
extern const GUID DETOUR_EXE_RESTORE_GUID;
extern const GUID DETOUR_EXE_HELPER_GUID;
#define DETOUR_TRAMPOLINE_SIGNATURE 0x21727444 // Dtr!
typedef struct _DETOUR_TRAMPOLINE DETOUR_TRAMPOLINE, *PDETOUR_TRAMPOLINE;
/////////////////////////////////////////////////////////// Binary Structures.
//
#pragma pack(push, 8)
typedef struct _DETOUR_SECTION_HEADER
{
DWORD cbHeaderSize;
DWORD nSignature;
DWORD nDataOffset;
DWORD cbDataSize;
DWORD nOriginalImportVirtualAddress;
DWORD nOriginalImportSize;
DWORD nOriginalBoundImportVirtualAddress;
DWORD nOriginalBoundImportSize;
DWORD nOriginalIatVirtualAddress;
DWORD nOriginalIatSize;
DWORD nOriginalSizeOfImage;
DWORD cbPrePE;
DWORD nOriginalClrFlags;
DWORD reserved1;
DWORD reserved2;
DWORD reserved3;
// Followed by cbPrePE bytes of data.
} DETOUR_SECTION_HEADER, *PDETOUR_SECTION_HEADER;
typedef struct _DETOUR_SECTION_RECORD
{
DWORD cbBytes;
DWORD nReserved;
GUID guid;
} DETOUR_SECTION_RECORD, *PDETOUR_SECTION_RECORD;
typedef struct _DETOUR_CLR_HEADER
{
// Header versioning
ULONG cb;
USHORT MajorRuntimeVersion;
USHORT MinorRuntimeVersion;
// Symbol table and startup information
IMAGE_DATA_DIRECTORY MetaData;
ULONG Flags;
// Followed by the rest of the IMAGE_COR20_HEADER
} DETOUR_CLR_HEADER, *PDETOUR_CLR_HEADER;
typedef struct _DETOUR_EXE_RESTORE
{
DWORD cb;
DWORD cbidh;
DWORD cbinh;
DWORD cbclr;
PBYTE pidh;
PBYTE pinh;
PBYTE pclr;
IMAGE_DOS_HEADER idh;
union {
IMAGE_NT_HEADERS inh;
IMAGE_NT_HEADERS32 inh32;
IMAGE_NT_HEADERS64 inh64;
BYTE raw[sizeof(IMAGE_NT_HEADERS64) +
sizeof(IMAGE_SECTION_HEADER) * 32];
};
DETOUR_CLR_HEADER clr;
} DETOUR_EXE_RESTORE, *PDETOUR_EXE_RESTORE;
typedef struct _DETOUR_EXE_HELPER
{
DWORD cb;
DWORD pid;
CHAR DllName[MAX_PATH];
} DETOUR_EXE_HELPER, *PDETOUR_EXE_HELPER;
#pragma pack(pop)
#define DETOUR_SECTION_HEADER_DECLARE(cbSectionSize) \
{ \
sizeof(DETOUR_SECTION_HEADER),\
DETOUR_SECTION_HEADER_SIGNATURE,\
sizeof(DETOUR_SECTION_HEADER),\
(cbSectionSize),\
\
0,\
0,\
0,\
0,\
\
0,\
0,\
0,\
0,\
}
/////////////////////////////////////////////////////////////// Helper Macros.
//
#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x)
#define DETOURS_STRINGIFY_(x) #x
///////////////////////////////////////////////////////////// Binary Typedefs.
//
typedef BOOL (CALLBACK *PF_DETOUR_BINARY_BYWAY_CALLBACK)(PVOID pContext,
PCHAR pszFile,
PCHAR *ppszOutFile);
typedef BOOL (CALLBACK *PF_DETOUR_BINARY_FILE_CALLBACK)(PVOID pContext,
PCHAR pszOrigFile,
PCHAR pszFile,
PCHAR *ppszOutFile);
typedef BOOL (CALLBACK *PF_DETOUR_BINARY_SYMBOL_CALLBACK)(PVOID pContext,
ULONG nOrigOrdinal,
ULONG nOrdinal,
ULONG *pnOutOrdinal,
PCHAR pszOrigSymbol,
PCHAR pszSymbol,
PCHAR *ppszOutSymbol);
typedef BOOL (CALLBACK *PF_DETOUR_BINARY_COMMIT_CALLBACK)(PVOID pContext);
typedef BOOL (CALLBACK *PF_DETOUR_ENUMERATE_EXPORT_CALLBACK)(PVOID pContext,
ULONG nOrdinal,
PCHAR pszName,
PVOID pCode);
typedef BOOL (CALLBACK *PF_DETOUR_IMPORT_FILE_CALLBACK)(PVOID pContext,
HMODULE hModule,
PCSTR pszFile);
typedef BOOL (CALLBACK *PF_DETOUR_IMPORT_FUNC_CALLBACK)(PVOID pContext,
DWORD nOrdinal,
PCSTR pszFunc,
PVOID pvFunc);
typedef VOID * PDETOUR_BINARY;
typedef VOID * PDETOUR_LOADED_BINARY;
//////////////////////////////////////////////////////////// Transaction APIs.
//
LONG WINAPI DetourTransactionBegin(VOID);
LONG WINAPI DetourTransactionAbort(VOID);
LONG WINAPI DetourTransactionCommit(VOID);
LONG WINAPI DetourTransactionCommitEx(PVOID **pppFailedPointer);
LONG WINAPI DetourUpdateThread(HANDLE hThread);
LONG WINAPI DetourAttach(PVOID *ppPointer,
PVOID pDetour);
LONG WINAPI DetourAttachEx(PVOID *ppPointer,
PVOID pDetour,
PDETOUR_TRAMPOLINE *ppRealTrampoline,
PVOID *ppRealTarget,
PVOID *ppRealDetour);
LONG WINAPI DetourDetach(PVOID *ppPointer,
PVOID pDetour);
BOOL WINAPI DetourSetIgnoreTooSmall(BOOL fIgnore);
BOOL WINAPI DetourSetRetainRegions(BOOL fRetain);
////////////////////////////////////////////////////////////// Code Functions.
//
PVOID WINAPI DetourFindFunction(PCSTR pszModule, PCSTR pszFunction);
PVOID WINAPI DetourCodeFromPointer(PVOID pPointer, PVOID *ppGlobals);
PVOID WINAPI DetourCopyInstruction(PVOID pDst,
PVOID *pDstPool,
PVOID pSrc,
PVOID *ppTarget,
LONG *plExtra);
///////////////////////////////////////////////////// Loaded Binary Functions.
//
HMODULE WINAPI DetourGetContainingModule(PVOID pvAddr);
HMODULE WINAPI DetourEnumerateModules(HMODULE hModuleLast);
PVOID WINAPI DetourGetEntryPoint(HMODULE hModule);
ULONG WINAPI DetourGetModuleSize(HMODULE hModule);
BOOL WINAPI DetourEnumerateExports(HMODULE hModule,
PVOID pContext,
PF_DETOUR_ENUMERATE_EXPORT_CALLBACK pfExport);
BOOL WINAPI DetourEnumerateImports(HMODULE hModule,
PVOID pContext,
PF_DETOUR_IMPORT_FILE_CALLBACK pfImportFile,
PF_DETOUR_IMPORT_FUNC_CALLBACK pfImportFunc);
PVOID WINAPI DetourFindPayload(HMODULE hModule, REFGUID rguid, DWORD *pcbData);
PVOID WINAPI DetourFindPayloadEx(REFGUID rguid, DWORD * pcbData);
DWORD WINAPI DetourGetSizeOfPayloads(HMODULE hModule);
///////////////////////////////////////////////// Persistent Binary Functions.
//
PDETOUR_BINARY WINAPI DetourBinaryOpen(HANDLE hFile);
PVOID WINAPI DetourBinaryEnumeratePayloads(PDETOUR_BINARY pBinary,
GUID *pGuid,
DWORD *pcbData,
DWORD *pnIterator);
PVOID WINAPI DetourBinaryFindPayload(PDETOUR_BINARY pBinary,
REFGUID rguid,
DWORD *pcbData);
PVOID WINAPI DetourBinarySetPayload(PDETOUR_BINARY pBinary,
REFGUID rguid,
PVOID pData,
DWORD cbData);
BOOL WINAPI DetourBinaryDeletePayload(PDETOUR_BINARY pBinary, REFGUID rguid);
BOOL WINAPI DetourBinaryPurgePayloads(PDETOUR_BINARY pBinary);
BOOL WINAPI DetourBinaryResetImports(PDETOUR_BINARY pBinary);
BOOL WINAPI DetourBinaryEditImports(PDETOUR_BINARY pBinary,
PVOID pContext,
PF_DETOUR_BINARY_BYWAY_CALLBACK pfByway,
PF_DETOUR_BINARY_FILE_CALLBACK pfFile,
PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbol,
PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommit);
BOOL WINAPI DetourBinaryWrite(PDETOUR_BINARY pBinary, HANDLE hFile);
BOOL WINAPI DetourBinaryClose(PDETOUR_BINARY pBinary);
/////////////////////////////////////////////////// Create Process & Load Dll.
//
typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEA)
(LPCSTR lpApplicationName,
LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation);
typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEW)
(LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation);
BOOL WINAPI DetourCreateProcessWithDllA(LPCSTR lpApplicationName,
__in_z LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation,
LPCSTR lpDllName,
PDETOUR_CREATE_PROCESS_ROUTINEA
pfCreateProcessA);
BOOL WINAPI DetourCreateProcessWithDllW(LPCWSTR lpApplicationName,
__in_z LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation,
LPCSTR lpDllName,
PDETOUR_CREATE_PROCESS_ROUTINEW
pfCreateProcessW);
#ifdef UNICODE
#define DetourCreateProcessWithDll DetourCreateProcessWithDllW
#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW
#else
#define DetourCreateProcessWithDll DetourCreateProcessWithDllA
#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA
#endif // !UNICODE
BOOL WINAPI DetourCreateProcessWithDllExA(LPCSTR lpApplicationName,
__in_z LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation,
LPCSTR lpDllName,
PDETOUR_CREATE_PROCESS_ROUTINEA
pfCreateProcessA);
BOOL WINAPI DetourCreateProcessWithDllExW(LPCWSTR lpApplicationName,
__in_z LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation,
LPCSTR lpDllName,
PDETOUR_CREATE_PROCESS_ROUTINEW
pfCreateProcessW);
#ifdef UNICODE
#define DetourCreateProcessWithDllEx DetourCreateProcessWithDllExW
#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW
#else
#define DetourCreateProcessWithDllEx DetourCreateProcessWithDllExA
#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA
#endif // !UNICODE
BOOL WINAPI DetourProcessViaHelperA(DWORD dwTargetPid,
LPCSTR lpDllName,
PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA);
BOOL WINAPI DetourProcessViaHelperW(DWORD dwTargetPid,
LPCSTR lpDllName,
PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW);
#ifdef UNICODE
#define DetourProcessViaHelper DetourProcessViaHelperW
#else
#define DetourProcessViaHelper DetourProcessViaHelperA
#endif // !UNICODE
BOOL WINAPI DetourUpdateProcessWithDll(HANDLE hProcess,
LPCSTR *plpDlls,
DWORD nDlls);
BOOL WINAPI DetourCopyPayloadToProcess(HANDLE hProcess,
REFGUID rguid,
PVOID pvData,
DWORD cbData);
BOOL WINAPI DetourRestoreAfterWith(VOID);
BOOL WINAPI DetourRestoreAfterWithEx(PVOID pvData, DWORD cbData);
BOOL WINAPI DetourIsHelperProcess(VOID);
VOID CALLBACK DetourFinishHelperProcess(HWND, HINSTANCE, LPSTR, INT);
//
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif // __cplusplus
//////////////////////////////////////////////// Detours Internal Definitions.
//
#ifdef __cplusplus
#ifdef DETOURS_INTERNAL
#ifndef __deref_out
#define __deref_out
#endif
#ifndef __deref
#define __deref
#endif
//////////////////////////////////////////////////////////////////////////////
//
#if (_MSC_VER < 1299)
#include <imagehlp.h>
typedef IMAGEHLP_MODULE IMAGEHLP_MODULE64;
typedef PIMAGEHLP_MODULE PIMAGEHLP_MODULE64;
typedef IMAGEHLP_SYMBOL SYMBOL_INFO;
typedef PIMAGEHLP_SYMBOL PSYMBOL_INFO;
static inline
LONG InterlockedCompareExchange(LONG *ptr, LONG nval, LONG oval)
{
return (LONG)::InterlockedCompareExchange((PVOID*)ptr, (PVOID)nval, (PVOID)oval);
}
#else
#include <dbghelp.h>
#endif
#ifdef IMAGEAPI // defined by DBGHELP.H
typedef LPAPI_VERSION (NTAPI *PF_ImagehlpApiVersionEx)(LPAPI_VERSION AppVersion);
typedef BOOL (NTAPI *PF_SymInitialize)(IN HANDLE hProcess,
IN LPCSTR UserSearchPath,
IN BOOL fInvadeProcess);
typedef DWORD (NTAPI *PF_SymSetOptions)(IN DWORD SymOptions);
typedef DWORD (NTAPI *PF_SymGetOptions)(VOID);
typedef DWORD64 (NTAPI *PF_SymLoadModule64)(IN HANDLE hProcess,
IN HANDLE hFile,
IN PSTR ImageName,
IN PSTR ModuleName,
IN DWORD64 BaseOfDll,
IN DWORD SizeOfDll);
typedef BOOL (NTAPI *PF_SymGetModuleInfo64)(IN HANDLE hProcess,
IN DWORD64 qwAddr,
OUT PIMAGEHLP_MODULE64 ModuleInfo);
typedef BOOL (NTAPI *PF_SymFromName)(IN HANDLE hProcess,
IN LPSTR Name,
OUT PSYMBOL_INFO Symbol);
typedef struct _DETOUR_SYM_INFO
{
HANDLE hProcess;
HMODULE hDbgHelp;
PF_ImagehlpApiVersionEx pfImagehlpApiVersionEx;
PF_SymInitialize pfSymInitialize;
PF_SymSetOptions pfSymSetOptions;
PF_SymGetOptions pfSymGetOptions;
PF_SymLoadModule64 pfSymLoadModule64;
PF_SymGetModuleInfo64 pfSymGetModuleInfo64;
PF_SymFromName pfSymFromName;
} DETOUR_SYM_INFO, *PDETOUR_SYM_INFO;
PDETOUR_SYM_INFO DetourLoadDbgHelp(VOID);
#endif // IMAGEAPI
#ifndef DETOUR_TRACE
#if DETOUR_DEBUG
#define DETOUR_TRACE(x) printf x
#define DETOUR_BREAK() __debugbreak()
#include <stdio.h>
#include <limits.h>
#else
#define DETOUR_TRACE(x)
#define DETOUR_BREAK()
#endif
#endif
#ifdef DETOURS_IA64
__declspec(align(16)) struct DETOUR_IA64_BUNDLE
{
public:
union
{
BYTE data[16];
UINT64 wide[2];
};
public:
struct DETOUR_IA64_METADATA;
typedef BOOL (DETOUR_IA64_BUNDLE::* DETOUR_IA64_METACOPY)
(const DETOUR_IA64_METADATA *pMeta, DETOUR_IA64_BUNDLE *pDst) const;
enum {
A_UNIT = 1u,
I_UNIT = 2u,
M_UNIT = 3u,
B_UNIT = 4u,
F_UNIT = 5u,
L_UNIT = 6u,
X_UNIT = 7u,
UNIT_MASK = 7u,
STOP = 8u
};
struct DETOUR_IA64_METADATA
{
ULONG nTemplate : 8; // Instruction template.
ULONG nUnit0 : 4; // Unit for slot 0
ULONG nUnit1 : 4; // Unit for slot 1
ULONG nUnit2 : 4; // Unit for slot 2
DETOUR_IA64_METACOPY pfCopy; // Function pointer.
};
protected:
BOOL CopyBytes(const DETOUR_IA64_METADATA *pMeta, DETOUR_IA64_BUNDLE *pDst) const;
BOOL CopyBytesMMB(const DETOUR_IA64_METADATA *pMeta, DETOUR_IA64_BUNDLE *pDst) const;
BOOL CopyBytesMBB(const DETOUR_IA64_METADATA *pMeta, DETOUR_IA64_BUNDLE *pDst) const;
BOOL CopyBytesBBB(const DETOUR_IA64_METADATA *pMeta, DETOUR_IA64_BUNDLE *pDst) const;
BOOL CopyBytesMLX(const DETOUR_IA64_METADATA *pMeta, DETOUR_IA64_BUNDLE *pDst) const;
static const DETOUR_IA64_METADATA s_rceCopyTable[33];
public:
// 120 112 104 96 88 80 72 64 56 48 40 32 24 16 8 0
// f. e. d. c. b. a. 9. 8. 7. 6. 5. 4. 3. 2. 1. 0.
// 00
// f.e. d.c. b.a. 9.8. 7.6. 5.4. 3.2. 1.0.
// 0000 0000 0000 0000 0000 0000 0000 001f : Template [4..0]
// 0000 0000 0000 0000 0000 03ff ffff ffe0 : Zero [ 41.. 5]
// 0000 0000 0000 0000 0000 3c00 0000 0000 : Zero [ 45.. 42]
// 0000 0000 0007 ffff ffff c000 0000 0000 : One [ 82.. 46]
// 0000 0000 0078 0000 0000 0000 0000 0000 : One [ 86.. 83]
// 0fff ffff ff80 0000 0000 0000 0000 0000 : Two [123.. 87]
// f000 0000 0000 0000 0000 0000 0000 0000 : Two [127..124]
BYTE GetTemplate() const;
BYTE GetInst0() const;
BYTE GetInst1() const;
BYTE GetInst2() const;
BYTE GetUnit0() const;
BYTE GetUnit1() const;
BYTE GetUnit2() const;
UINT64 GetData0() const;
UINT64 GetData1() const;
UINT64 GetData2() const;
public:
BOOL IsBrl() const;
VOID SetBrl();
VOID SetBrl(UINT64 target);
UINT64 GetBrlTarget() const;
VOID SetBrlTarget(UINT64 target);
VOID SetBrlImm(UINT64 imm);
UINT64 GetBrlImm() const;
BOOL IsMovlGp() const;
UINT64 GetMovlGp() const;
VOID SetMovlGp(UINT64 gp);
VOID SetInst0(BYTE nInst);
VOID SetInst1(BYTE nInst);
VOID SetInst2(BYTE nInst);
VOID SetData0(UINT64 nData);
VOID SetData1(UINT64 nData);
VOID SetData2(UINT64 nData);
BOOL SetNop0();
BOOL SetNop1();
BOOL SetNop2();
BOOL SetStop();
BOOL Copy(DETOUR_IA64_BUNDLE *pDst) const;
};
#endif // DETOURS_IA64
//#ifdef DETOURS_ARM
//#error Feature not supported in this release.
//#endif // DETOURS_ARM
//////////////////////////////////////////////////////////////////////////////
#endif // DETOURS_INTERNAL
#endif // __cplusplus
#endif // _DETOURS_H_
//
//////////////////////////////////////////////////////////////// End of File.

Binary file not shown.

View File

@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////////////////
//
// Common version parameters.
//
// Microsoft Research Detours Package, Version 3.0 Build_316.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#ifndef DETOURS_STRINGIFY
#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x)
#define DETOURS_STRINGIFY_(x) #x
#endif
#define VER_FILEFLAGSMASK 0x3fL
#define VER_FILEFLAGS 0x0L
#define VER_FILEOS 0x00040004L
#define VER_FILETYPE 0x00000002L
#define VER_FILESUBTYPE 0x00000000L
#define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS)

View File

@@ -0,0 +1,58 @@
#pragma once
#include "Utils/Memory.h"
enum EClientFrameStage : int
{
FRAME_UNDEFINED = -1,
FRAME_START,
FRAME_NET_UPDATE_START,
FRAME_NET_UPDATE_POSTDATAUPDATE_START,
FRAME_NET_UPDATE_POSTDATAUPDATE_END,
FRAME_NET_UPDATE_END,
FRAME_RENDER_START,
FRAME_RENDER_END,
FRAME_NET_FULL_FRAME_UPDATE_ON_REMOVE
};
class IEngineClient
{
public:
int GetMaxClients()
{
return M::CallVFunc<int, 34U>(this);
}
bool IsInGame()
{
return M::CallVFunc<bool, 35U>(this);
}
bool IsConnected()
{
return M::CallVFunc<bool, 36U>(this);
}
int GetLocalPlayer()
{
int nIndex = -1;
M::CallVFunc<void, 47U>(this, std::ref(nIndex), 0);
return nIndex + 1;
}
const char* GetLevelName()
{
return M::CallVFunc<const char*, 56U>(this);
}
const char* GetLevelNameShort()
{
return M::CallVFunc<const char*, 57U>(this);
}
const char* GetProductVersionString()
{
return M::CallVFunc<const char*, 81U>(this);
}
};

View File

@@ -0,0 +1,31 @@
#pragma once
// used: mem::CallVFunc
#include "Utils/Memory.h"
#pragma warning(push)
#pragma warning(disable : 4191)
class IMemAlloc
{
public:
void* Alloc(std::size_t nSize)
{
return M::CallVFunc<void*, 1>(this, nSize);
}
void* ReAlloc(const void* pMemory, std::size_t nSize)
{
return M::CallVFunc<void*, 2>(this, pMemory, nSize);
}
void Free(const void* pMemory)
{
return M::CallVFunc<void, 3>(this, pMemory);
}
std::size_t GetSize(const void* pMemory)
{
return M::CallVFunc<std::size_t, 21>(this, pMemory);
}
};
#pragma warning(pop)

View File

@@ -0,0 +1,252 @@
#pragma once
#include <cmath>
#include <limits>
template <typename T>
inline constexpr const T& ClampAngles(const T& value, const T& minimal, const T& maximal) noexcept
{
return (value < minimal) ? minimal : (value > maximal) ? maximal :
value;
}
struct QAngle_t
{
constexpr QAngle_t(float x = 0.f, float y = 0.f, float z = 0.f) :
x(x), y(y), z(z) { }
constexpr QAngle_t(const float* arrAngles) :
x(arrAngles[0]), y(arrAngles[1]), z(arrAngles[2]) { }
#pragma region qangle_array_operators
[[nodiscard]] float& operator[](const int nIndex)
{
return reinterpret_cast<float*>(this)[nIndex];
}
[[nodiscard]] const float& operator[](const int nIndex) const
{
return reinterpret_cast<const float*>(this)[nIndex];
}
#pragma endregion
#pragma region qangle_relational_operators
bool operator==(const QAngle_t& angBase) const
{
return this->IsEqual(angBase);
}
bool operator!=(const QAngle_t& angBase) const
{
return !this->IsEqual(angBase);
}
#pragma endregion
#pragma region qangle_assignment_operators
constexpr QAngle_t& operator=(const QAngle_t& angBase)
{
this->x = angBase.x;
this->y = angBase.y;
this->z = angBase.z;
return *this;
}
#pragma endregion
#pragma region qangle_arithmetic_assignment_operators
constexpr QAngle_t& operator+=(const QAngle_t& angBase)
{
this->x += angBase.x;
this->y += angBase.y;
this->z += angBase.z;
return *this;
}
constexpr QAngle_t& operator-=(const QAngle_t& angBase)
{
this->x -= angBase.x;
this->y -= angBase.y;
this->z -= angBase.z;
return *this;
}
constexpr QAngle_t& operator*=(const QAngle_t& angBase)
{
this->x *= angBase.x;
this->y *= angBase.y;
this->z *= angBase.z;
return *this;
}
constexpr QAngle_t& operator/=(const QAngle_t& angBase)
{
this->x /= angBase.x;
this->y /= angBase.y;
this->z /= angBase.z;
return *this;
}
constexpr QAngle_t& operator+=(const float flAdd)
{
this->x += flAdd;
this->y += flAdd;
this->z += flAdd;
return *this;
}
constexpr QAngle_t& operator-=(const float flSubtract)
{
this->x -= flSubtract;
this->y -= flSubtract;
this->z -= flSubtract;
return *this;
}
constexpr QAngle_t& operator*=(const float flMultiply)
{
this->x *= flMultiply;
this->y *= flMultiply;
this->z *= flMultiply;
return *this;
}
constexpr QAngle_t& operator/=(const float flDivide)
{
this->x /= flDivide;
this->y /= flDivide;
this->z /= flDivide;
return *this;
}
#pragma endregion
#pragma region qangle_arithmetic_unary_operators
constexpr QAngle_t& operator-()
{
this->x = -this->x;
this->y = -this->y;
this->z = -this->z;
return *this;
}
constexpr QAngle_t operator-() const
{
return { -this->x, -this->y, -this->z };
}
#pragma endregion
#pragma region qangle_arithmetic_ternary_operators
constexpr QAngle_t operator+(const QAngle_t& angAdd) const
{
return { this->x + angAdd.x, this->y + angAdd.y, this->z + angAdd.z };
}
constexpr QAngle_t operator-(const QAngle_t& angSubtract) const
{
return { this->x - angSubtract.x, this->y - angSubtract.y, this->z - angSubtract.z };
}
constexpr QAngle_t operator*(const QAngle_t& angMultiply) const
{
return { this->x * angMultiply.x, this->y * angMultiply.y, this->z * angMultiply.z };
}
constexpr QAngle_t operator/(const QAngle_t& angDivide) const
{
return { this->x / angDivide.x, this->y / angDivide.y, this->z / angDivide.z };
}
constexpr QAngle_t operator+(const float flAdd) const
{
return { this->x + flAdd, this->y + flAdd, this->z + flAdd };
}
constexpr QAngle_t operator-(const float flSubtract) const
{
return { this->x - flSubtract, this->y - flSubtract, this->z - flSubtract };
}
constexpr QAngle_t operator*(const float flMultiply) const
{
return { this->x * flMultiply, this->y * flMultiply, this->z * flMultiply };
}
constexpr QAngle_t operator/(const float flDivide) const
{
return { this->x / flDivide, this->y / flDivide, this->z / flDivide };
}
#pragma endregion
// @returns : true if each component of angle is finite, false otherwise
[[nodiscard]] bool IsValid() const
{
return (std::isfinite(this->x) && std::isfinite(this->y) && std::isfinite(this->z));
}
/// @returns: true if each component of angle equals to another, false otherwise
[[nodiscard]] bool IsEqual(const QAngle_t& angEqual, const float flErrorMargin = std::numeric_limits<float>::epsilon()) const
{
return (std::fabsf(this->x - angEqual.x) < flErrorMargin && std::fabsf(this->y - angEqual.y) < flErrorMargin && std::fabsf(this->z - angEqual.z) < flErrorMargin);
}
/// @returns: true if each component of angle equals zero, false otherwise
[[nodiscard]] bool IsZero() const
{
// @test: to make this implementation right, we should use fpclassify here, but game aren't doing same, probably it's better to keep this same, just ensure that it will be compiled same
return (this->x == 0.0f && this->y == 0.0f && this->z == 0.0f);
}
/// @returns: length of hypotenuse
[[nodiscard]] float Length2D() const
{
return std::sqrtf(x * x + y * y);
}
/// clamp each angle component by minimal/maximal allowed value for source sdk games
/// @returns: clamped angle
constexpr QAngle_t& Clamp()
{
this->x = ClampAngles(this->x, -89.f, 89.f);
this->y = ClampAngles(this->y, -180.f, 180.f);
this->z = ClampAngles(this->z, -45.f, 45.f);
return *this;
}
/// map polar angles to the range of [-180, 180] degrees
/// @returns: normalized angle
QAngle_t& Normalize()
{
this->x = std::remainderf(this->x, 360.f);
this->y = std::remainderf(this->y, 360.f);
this->z = std::remainderf(this->z, 360.f);
return *this;
}
QAngle_t Delta(const QAngle_t& other) const
{
QAngle_t delta;
delta.x = x - other.x;
delta.y = y - other.y;
delta.z = z - other.z;
delta.Normalize();
return delta;
}
float Length() const
{
return sqrt(x * x + y * y + z * z);
}
public:
float x = 0.0f, y = 0.0f, z = 0.0f;
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include "Utils/Memory.h"
class CUtlBuffer
{
public:
MEM_PAD(0x80);
CUtlBuffer(int a1, int nSize, int a3)
{
M::fnUtlBufferInit != nullptr;
M::fnUtlBufferInit(this, a1, nSize, a3);
}
void PutString(const char* szString)
{
M::fnUtlBufferPutString != nullptr;
M::fnUtlBufferPutString(this, szString);
}
void EnsureCapacity(int nSize)
{
M::fnUtlBufferEnsureCapacity != nullptr;
M::fnUtlBufferEnsureCapacity(this, nSize);
}
};