Skip to content

Commit

Permalink
Merge pull request #142 from ByteCorum/WIP
Browse files Browse the repository at this point in the history
`GetProcessID` moved to kernel; Changes
  • Loading branch information
ByteCorum authored Sep 20, 2024
2 parents 529c8e9 + ac65ed0 commit 0d79afc
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 115 deletions.
4 changes: 2 additions & 2 deletions DragonBurn/Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace MenuConfig
{
inline std::string name = "DragonBurn";
inline std::string version = "2.0.1.5";
inline std::string version = "2.0.2.5";
inline std::string author = "ByteCorum";

inline std::string path = "";
inline std::string docPath = "";
inline int RenderFPS = 100000.0f;
inline int RenderFPS = 1000000.0f;
inline int RenderDistance = 1000;


Expand Down
8 changes: 4 additions & 4 deletions DragonBurn/Core/GUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ namespace GUI

ImGui::SeparatorText("External Radar");
float RadarPointSizeProportionMin = 0.2f, RadarPointSizeProportionMax = 2.f;
float ProportionMin = 500.f, ProportionMax = 10000.f;
float ProportionMin = 500.f, ProportionMax = 15000.f;
float RadarRangeMin = 100.f, RadarRangeMax = 300.f;
float AlphaMin = 0.f, AlphaMax = 1.f;
PutSwitch(Text::Radar::Toggle.c_str(), 5.f, ImGui::GetFrameHeight() * 1.7, &RadarCFG::ShowRadar);
Expand All @@ -360,7 +360,7 @@ namespace GUI
if (RadarCFG::customRadar)
{
PutSwitch(Text::Radar::CrossLine.c_str(), 5.f, ImGui::GetFrameHeight() * 1.7, &RadarCFG::ShowRadarCrossLine);
PutSliderFloat(Text::Radar::SizeSlider.c_str(), 5.f, &RadarCFG::RadarPointSizeProportion, &RadarPointSizeProportionMin, &RadarPointSizeProportionMax, "%1.f");
PutSliderFloat(Text::Radar::SizeSlider.c_str(), 5.f, &RadarCFG::RadarPointSizeProportion, &RadarPointSizeProportionMin, &RadarPointSizeProportionMax, "%.1f");
PutSliderFloat(Text::Radar::ProportionSlider.c_str(), 5.f, &RadarCFG::Proportion, &ProportionMin, &ProportionMax, "%.1f");
PutSliderFloat(Text::Radar::RangeSlider.c_str(), 5.f, &RadarCFG::RadarRange, &RadarRangeMin, &RadarRangeMax, "%.1f");
PutSliderFloat(Text::Radar::AlphaSlider.c_str(), 5.f, &RadarCFG::RadarBgAlpha, &AlphaMin, &AlphaMax, "%.1f");
Expand Down Expand Up @@ -406,9 +406,9 @@ namespace GUI
ImGui::SetCursorPos(ImVec2(15.f, 24.f));
ImGui::SeparatorText("Aimbot");

float FovMin = 0.f, FovMax = 25.f, MinFovMax = 1.f;
float FovMin = 0.f, FovMax = 30.f, MinFovMax = 1.f;
int BulletMin = 0, BulletMax = 5;
float SmoothMin = 1.f, SmoothMax = 10.f;
float SmoothMin = 1.f, SmoothMax = 15.f;
PutSwitch(Text::Aimbot::Enable.c_str(), 10.f, ImGui::GetFrameHeight() * 1.7, &LegitBotConfig::AimBot);
if (LegitBotConfig::AimBot)
{
Expand Down
35 changes: 18 additions & 17 deletions DragonBurn/Core/Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ namespace Init
return false;
}

static void RandTitle()
{
srand(time(0));
constexpr int length = 25;
const auto characters = TEXT("0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM");
TCHAR title[length + 1]{};

for (int j = 0; j != length; j++)
{
title[j] += characters[rand() % 63];
}

SetConsoleTitle(title);
}
//static void RandTitle()
//{
// srand(time(0));
// constexpr int length = 25;
// const auto characters = TEXT("0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM");
// TCHAR title[length + 1]{};

// for (int j = 0; j < length; j++)
// {
// title[j] += characters[rand() % 63];
// }

// SetConsoleTitle(title);
//}

static int CheckCheatVersion()
{
Expand Down Expand Up @@ -91,19 +91,20 @@ namespace Init

static int CheckCS2Version()
{
DWORD pid = MemoryMgr::GetProcessID(L"cs2.exe");
long curVer;
const std::string cloudVersionUrl = "https://raw.githubusercontent.com/ByteCorum/DragonBurn/data/cs2-version";
long cloudVersion;
std::string processPath;
std::string buff;
long cloudVersion;

if (!Web::Get(cloudVersionUrl, buff))
return 2;
cloudVersion = stoi(buff);
if (cloudVersion == -1)
return 3;

DWORD pid = memoryManager.GetProcessID(L"cs2.exe");
std::string processPath;

HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
if (hProcess)
{
Expand Down
102 changes: 31 additions & 71 deletions DragonBurn/Core/MemoryMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,27 @@ bool MemoryMgr::Attach(const DWORD pid)
return true;
}

DWORD64 MemoryMgr::TraceAddress(DWORD64 baseAddress, std::vector<DWORD> offsets)
DWORD MemoryMgr::GetProcessID(const wchar_t* processName)
{
if (kernelDriver != nullptr && ProcessID != 0)
if (kernelDriver != nullptr)
{
DWORD64 address = 0;
PID_PACK PidPack;
RtlZeroMemory(PidPack.name, 1024);
wcsncpy(PidPack.name, processName, 1024);

if (offsets.size() == 0)
return baseAddress;
BOOL result = DeviceIoControl(kernelDriver,
IOCTL_GET_PID,
&PidPack,
sizeof(PidPack),
&PidPack,
sizeof(PidPack),
nullptr,
nullptr);

if (!ReadMemory<DWORD64>(baseAddress, address))
if (result == TRUE)
return PidPack.pid;
else
return 0;

for (int i = 0; i < offsets.size() - 1; i++)
{
if (!ReadMemory<DWORD64>(address + offsets[i], address))
return 0;
}
return address == 0 ? 0 : address + offsets[offsets.size() - 1];
}
else
return 0;
Expand Down Expand Up @@ -94,68 +97,25 @@ DWORD64 MemoryMgr::GetModuleBase(const wchar_t* moduleName)
return 0;
}

DWORD MemoryMgr::GetProcessID(const wchar_t* processName)
DWORD64 MemoryMgr::TraceAddress(DWORD64 baseAddress, std::vector<DWORD> offsets)
{
DWORD processId = 0;
HANDLE snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

if (snapShot == INVALID_HANDLE_VALUE)
return processId;
if (kernelDriver != nullptr && ProcessID != 0)
{
DWORD64 address = 0;

PROCESSENTRY32W entry = {};
entry.dwSize = sizeof(decltype(entry));
if (offsets.size() == 0)
return baseAddress;

if (Process32FirstW(snapShot, &entry) == TRUE) // Check if the first handle is the one we want
{
if (_wcsicmp(processName, entry.szExeFile) == 0)
processId = entry.th32ProcessID;
if (!ReadMemory<DWORD64>(baseAddress, address))
return 0;

else
for (int i = 0; i < offsets.size() - 1; i++)
{
while (Process32NextW(snapShot, &entry) == TRUE)
{
if (_wcsicmp(processName, entry.szExeFile) == 0)
{
processId = entry.th32ProcessID;
break;
}
}
if (!ReadMemory<DWORD64>(address + offsets[i], address))
return 0;
}
return address == 0 ? 0 : address + offsets[offsets.size() - 1];
}

CloseHandle(snapShot);
return processId;
}

//DWORD64 MemoryMgr::GetModuleBase(const DWORD pid, const wchar_t* moduleName) {
// DWORD64 moduleBase = 0;
//
// // Snap-shot of process' modules (dlls).
// HANDLE snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid);
// if (snapShot == INVALID_HANDLE_VALUE)
// return moduleBase;
//
// MODULEENTRY32W entry = {};
// entry.dwSize = sizeof(decltype(entry));
//
// if (Module32FirstW(snapShot, &entry) == TRUE)
// {
// if (wcsstr(moduleName, entry.szModule) != nullptr)
// moduleBase = reinterpret_cast<DWORD64>(entry.modBaseAddr);
//
// else
// {
// while (Module32NextW(snapShot, &entry) == TRUE)
// {
// if (wcsstr(moduleName, entry.szModule) != nullptr)
// {
// moduleBase = reinterpret_cast<DWORD64>(entry.modBaseAddr);
// break;
// }
// }
// }
// }
//
// CloseHandle(snapShot);
// return moduleBase;
//}
else
return 0;
}
18 changes: 11 additions & 7 deletions DragonBurn/Core/MemoryMgr.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once
#include <iostream>
#include <Windows.h>
#include <Tlhelp32.h>
#include <string>
#include <vector>

#define DRAGON_DEVICE 0x8000
#define IOCTL_GET_PID CTL_CODE(DRAGON_DEVICE, 0x4452, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_GET_MODULE_BASE CTL_CODE(DRAGON_DEVICE, 0x4462, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_READ_PROCESS_MEMORY CTL_CODE(DRAGON_DEVICE, 0x4472, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_WRITE_PROCESS_MEMORY CTL_CODE(DRAGON_DEVICE, 0x4482, METHOD_NEITHER, FILE_ANY_ACCESS)
Expand All @@ -20,9 +20,11 @@ class MemoryMgr

bool ConnectDriver(const LPCWSTR);
bool DisconnectDriver();

bool Attach(const DWORD);

DWORD64 GetModuleBase(const wchar_t*);
DWORD GetProcessID(const wchar_t*);

template <typename ReadType>
bool ReadMemory(DWORD64 address, ReadType& value, SIZE_T size = sizeof(ReadType))
{
Expand All @@ -43,7 +45,6 @@ class MemoryMgr
nullptr,
nullptr);

//std::cout << result << " " << bytesReturned << " " << size << " " << readPack.Buffer << '\n';
return result == TRUE ; // && bytesReturned == size
}
return false;
Expand Down Expand Up @@ -100,15 +101,18 @@ class MemoryMgr
//}

DWORD64 TraceAddress(DWORD64, std::vector<DWORD>);
DWORD64 GetModuleBase(const wchar_t*);

static DWORD GetProcessID(const wchar_t*);
//static DWORD64 GetModuleBase(const DWORD, const wchar_t*);

private:
DWORD ProcessID;
HANDLE kernelDriver;

// Structure for getting pid by name
typedef struct _PID_PACK
{
UINT32 pid;
WCHAR name[1024];
} PID_PACK, * P_PID_PACK;

// Structure for getting module address base
typedef struct _MODULE_PACK {
UINT32 pid;
Expand Down
18 changes: 9 additions & 9 deletions DragonBurn/DragonBurn.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<Filter Include="Features\Misc">
<UniqueIdentifier>{b0c7adeb-2fdd-4355-93c2-b03f5946ffec}</UniqueIdentifier>
</Filter>
<Filter Include="Features\Aim">
<UniqueIdentifier>{bec5d160-9097-41fe-b2e1-d771a6544092}</UniqueIdentifier>
</Filter>
<Filter Include="Helpers">
<UniqueIdentifier>{d6ce1762-ee50-44d7-938a-7de7d8911330}</UniqueIdentifier>
</Filter>
Expand All @@ -40,6 +37,9 @@
<Filter Include="Offsets">
<UniqueIdentifier>{d41606d6-9efb-4793-9976-ae2deca558e7}</UniqueIdentifier>
</Filter>
<Filter Include="Features\Legit">
<UniqueIdentifier>{bec5d160-9097-41fe-b2e1-d771a6544092}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Resources\WeaponIcon.hpp">
Expand Down Expand Up @@ -127,10 +127,10 @@
<Filter>Features\Visual</Filter>
</ClInclude>
<ClInclude Include="Features\RCS.h">
<Filter>Features\Aim</Filter>
<Filter>Features\Legit</Filter>
</ClInclude>
<ClInclude Include="Features\TriggerBot.h">
<Filter>Features\Aim</Filter>
<Filter>Features\Legit</Filter>
</ClInclude>
<ClInclude Include="Helpers\Mouse.h">
<Filter>Helpers</Filter>
Expand Down Expand Up @@ -169,7 +169,7 @@
<Filter>Offsets</Filter>
</ClInclude>
<ClInclude Include="Features\Aimbot.h">
<Filter>Features\Aim</Filter>
<Filter>Features\Legit</Filter>
</ClInclude>
<ClInclude Include="Helpers\WebApi.h">
<Filter>Helpers</Filter>
Expand Down Expand Up @@ -240,7 +240,7 @@
<Filter>Features\Visual</Filter>
</ClCompile>
<ClCompile Include="Features\TriggerBot.cpp">
<Filter>Features\Aim</Filter>
<Filter>Features\Legit</Filter>
</ClCompile>
<ClCompile Include="Helpers\Mouse.cpp">
<Filter>Helpers</Filter>
Expand All @@ -258,13 +258,13 @@
<Filter>Config</Filter>
</ClCompile>
<ClCompile Include="Features\Aimbot.cpp">
<Filter>Features\Aim</Filter>
<Filter>Features\Legit</Filter>
</ClCompile>
<ClCompile Include="Offsets\Offsets.cpp">
<Filter>Offsets</Filter>
</ClCompile>
<ClCompile Include="Features\RCS.cpp">
<Filter>Features\Aim</Filter>
<Filter>Features\Legit</Filter>
</ClCompile>
<ClCompile Include="Core\MemoryMgr.cpp">
<Filter>Core</Filter>
Expand Down
2 changes: 1 addition & 1 deletion DragonBurn/Features/TriggerBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool TriggerBot::CheckScopeWeapon(const CEntity& LocalEntity)
return false;

std::string WeaponName = CEntity::GetWeaponName(weaponIndex);
if (WeaponName == "aug" || WeaponName == "awp" || WeaponName == "g3Sg1" || WeaponName == "sg556" || WeaponName == "ssg08" || WeaponName == "scar20")
if (WeaponName == "awp" || WeaponName == "g3Sg1" || WeaponName == "ssg08" || WeaponName == "scar20")
return true;
else
return false;
Expand Down
Binary file modified DragonBurn/Resources/Resource.rc
Binary file not shown.
7 changes: 4 additions & 3 deletions DragonBurn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ int main()
void Cheat()
{
ShowWindow(GetConsoleWindow(), SW_SHOWNORMAL);
Init::Verify::RandTitle();
SetConsoleTitle(L"DragonBurn");
//Init::Verify::RandTitle();

Log::Custom(R"LOGO(______ ______
| _ \ | ___ \
Expand Down Expand Up @@ -118,7 +119,7 @@ void Cheat()

std::cout << '\n';
bool preStart = false;
while (MemoryMgr::GetProcessID(L"cs2.exe") == 0)
while (memoryManager.GetProcessID(L"cs2.exe") == 0)
{
Log::PreviousLine();
Log::Info("Waiting for CS2");
Expand Down Expand Up @@ -164,7 +165,7 @@ void Cheat()
}
#endif

if (!memoryManager.Attach(MemoryMgr::GetProcessID(L"cs2.exe")))
if (!memoryManager.Attach(memoryManager.GetProcessID(L"cs2.exe")))
{
Log::PreviousLine();
Log::Error("Failed to attach to the process");
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img src="https://img.shields.io/badge/tests-100/100-76B900?style=for-the-badge&logo=&logoColor=whit">
<img src="https://img.shields.io/badge/code quality-A-76B900?style=for-the-badge&logo=&logoColor=whit">
<img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge&logo=&logoColor=whit">
<img src="https://img.shields.io/badge/DragonBurn-v2.0.1.5-blue?style=for-the-badge&logo=&logoColor=whit">
<img src="https://img.shields.io/badge/DragonBurn-v2.0.2.5-blue?style=for-the-badge&logo=&logoColor=whit">
<img src="https://img.shields.io/badge/CS2-000000?style=for-the-badge&logo=counter-strike&logoColor=white">
<img src="https://img.shields.io/badge/Kernel mode-28004D?style=for-the-badge&logo=webdriverio&logoColor=FFFFFF">
<img src="https://img.shields.io/badge/offsets auto update-D06B57?style=for-the-badge&logo=databricks&logoColor=FFFFFF">
Expand Down

0 comments on commit 0d79afc

Please sign in to comment.