From f07b2ff244c83328b19c82c9d724911958d0ae2b Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Thu, 16 Jul 2020 17:04:20 +0200 Subject: added license --- Source.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Source.cpp') diff --git a/Source.cpp b/Source.cpp index e4459e4..d6793c9 100644 --- a/Source.cpp +++ b/Source.cpp @@ -64,6 +64,7 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval { if (firstTime) { + printf("5\n"); firstTime = false; //only once //get device @@ -200,13 +201,14 @@ DWORD __stdcall InitHooks(LPVOID hModule) { OnDllAttach(hModule); + printf("1\n"); HMODULE hDXGIDLL = 0; do { hDXGIDLL = GetModuleHandleA("dxgi.dll"); Sleep(100); } while (!hDXGIDLL); - + printf("2\n"); IDXGISwapChain* pSwapChain; WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, DXGIMsgProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "DX", NULL }; @@ -268,7 +270,10 @@ DWORD __stdcall InitHooks(LPVOID hModule) phookD3D11Present = (D3D11PresentHook)(DWORD_PTR*)pSwapChainVtable[8]; VmtHook presentHook = VmtHook((void**)pSwapChainVtable); + + printf("3\n"); presentHook.Hook(8, hookD3D11Present); + printf("4\n"); pDevice->Release(); pContext->Release(); -- cgit v1.2.3 From cdc71b248d67fa5d1ac10a4a35ac3a58f757255e Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Fri, 31 Jul 2020 16:14:55 +0200 Subject: Working minimal version --- CastleManager.cpp | 4 +-- Classes.h | 74 +++++++++++++++++++++++++++++-------------------------- Core.cpp | 38 ++++++++++++++-------------- Debug.cpp | 4 +-- ESP.cpp | 53 ++++++++++++++++++++------------------- Engine.cpp | 11 +-------- Engine.h | 1 - MinimapText.cpp | 2 +- Offsets.cpp | 10 ++++---- RelicManager.cpp | 6 ++--- Source.cpp | 4 +-- 11 files changed, 101 insertions(+), 106 deletions(-) (limited to 'Source.cpp') diff --git a/CastleManager.cpp b/CastleManager.cpp index 373d6e5..2b7ab6f 100644 --- a/CastleManager.cpp +++ b/CastleManager.cpp @@ -39,13 +39,13 @@ void CastleManager::OnUnitCreated(Unit* unit) { return; } - Player* owningPlayer = unit->pOwner; + Player* owningPlayer = unit->GetOwner(); if (!owningPlayer || owningPlayer == Engine::Get()->GetLocalPlayer()) { return; } - if (strcmp("CSTL", unit->pUnitData->name) == 0) + if (strcmp("CSTL", unit->GetUnitData()->GetName()) == 0) { std::string message = std::string(owningPlayer->name) + " is building a castle!"; const char* charMessage = message.c_str(); diff --git a/Classes.h b/Classes.h index 6f4e3fe..8f91625 100644 --- a/Classes.h +++ b/Classes.h @@ -281,52 +281,56 @@ public: class UnitData { public: - char pad_0x0000[0x20]; //0x0000 - __int16 Class; //0x0020 - char pad_0x0022[0x26]; //0x0022 - __int16 unk; //0x0048 - __int16 maxHp; //0x004A - char pad_0x004C[0x8]; //0x004C - float collisionX; //0x0054 - float collisionY; //0x0058 - float collisionZ; //0x005C - char pad_0x0060[0x120]; //0x0060 - char* name; //0x0180 -}; //Size=0x0408 + char* GetName() + { + return *reinterpret_cast(*(uint64_t*)this + 0x848); + } + + Vector3 GetCollision() + { + return *(Vector3*)(*(uint64_t*)this + 0x718); + } + +}; class Unit { -public: - char pad_0x0000[0x10]; //0x0000 - UnitData* pUnitData; //0x0010 - Player* pOwner; //0x0018 - char pad_0x0020[0x70]; //0x0020 - float fHealth; //0x0090 - char pad_0x0094[0x4]; //0x0094 - Vector3 position; - - //When moving sadly height isnt set. When attack it works. - Vector3* GetTargetPosition() +private: + float GetPosX() + { + int32_t position = *reinterpret_cast((uint64_t)this + 0x1a0) ^ 0x187F64ADC21CDE88 ^ 0x4F019E376DDAD1E5; + return *(float*)(&position); + } + + float GetPosY() { - uint64_t actionList = *reinterpret_cast((uint64_t)this + 0x288); - if (!actionList){return NULL;} - uint64_t targetDataWrapper = *reinterpret_cast(actionList + 0x10); - if (!targetDataWrapper) { return NULL; } - uint64_t actionMoveTo = *reinterpret_cast(targetDataWrapper); - if (!actionMoveTo) { return NULL; } - return reinterpret_cast(actionMoveTo + 0x38); + int32_t position = *reinterpret_cast((uint64_t)this + 0x308) ^ 0x51E534524D81CFA6; + return *(float*)(&position); } + float GetPosZ() + { + int32_t position = (*reinterpret_cast((uint64_t)this + 0x3f8) - 0x17258AE0D9C58D92 ) ^ 0x78E0AFEAF822FC61; + return *(float*)(&position); + } +public: + + UnitData* GetUnitData() + { + return reinterpret_cast((uint64_t)this + 0x10); + } - typedef char(__fastcall* fhsMoveToCaller)(Unit* unit, Unit* targetUnit, World* world, int64_t zero, float xPos, float yPos, int zero2); - void MoveTo(World* world, float xPos, float yPos) + Player* GetOwner() { - static fhsMoveToCaller moveUnitCaller = (fhsMoveToCaller)((int64_t)GetModuleHandle(NULL) + 0xc863a0); //outdated and desync - moveUnitCaller(this, 0, world, 0, xPos, yPos, 0); + return *reinterpret_cast((uint64_t)this + 0x18); } -}; //Size=0x0250 + Vector3 GetPosition() + { + return Vector3(GetPosX(), GetPosY(), GetPosZ()); + } +}; class ObjectManager { diff --git a/Core.cpp b/Core.cpp index 5ff0aee..318fba2 100644 --- a/Core.cpp +++ b/Core.cpp @@ -82,20 +82,20 @@ void __fastcall OnCreateUnitHook(Registers* registers) Core::Core() { - printf("Core::Core()\n"); - onCreateUnitHook.Hook((BYTE*)GetModuleHandle(NULL) + Offsets::createUnitHook, (BYTE*)OnCreateUnitHook, 15); + //printf("Core::Core()\n"); + //onCreateUnitHook.Hook((BYTE*)GetModuleHandle(NULL) + Offsets::createUnitHook, (BYTE*)OnCreateUnitHook, 15); FeatureManager* featureManager = FeatureManager::Get(); - featureManager->RegisterFeature(new InitialiseOffsets()); + //featureManager->RegisterFeature(new InitialiseOffsets()); //Register Features here - featureManager->RegisterFeature(new ResourceInformation()); + //featureManager->RegisterFeature(new ResourceInformation()); featureManager->RegisterFeature(new ESP()); featureManager->RegisterFeature(new MinimapText()); - featureManager->RegisterFeature(new RelicManager()); - featureManager->RegisterFeature(new CustomLoadingScreen("C:\\wallpaper.jpg")); + //featureManager->RegisterFeature(new RelicManager()); + //featureManager->RegisterFeature(new CustomLoadingScreen("C:\\wallpaper.jpg")); //featureManager->RegisterFeature(new PauseManager()); - featureManager->RegisterFeature(new CastleManager()); + //featureManager->RegisterFeature(new CastleManager()); #ifdef _DEBUG featureManager->RegisterFeature(new Debug()); @@ -124,19 +124,20 @@ void createPlayerTreeNode(Player* player, int playerIndex) Unit* unit = player->pObjectManager->units[i]; if (!unit) { continue; } - if (unit->pOwner == player) + if (unit->GetOwner() == player) { ImGui::Text("%p", unit); ImGui::SameLine(); - ImGui::Text("%s", unit->pUnitData->name); + ImGui::Text("%s", unit->GetUnitData()->GetName()); + ImGui::Text("%f %f %f", unit->GetPosition().x, unit->GetPosition().y, unit->GetPosition().z); ImGui::SameLine(); - std::string text = std::string("Copy##") + std::string(unit->pUnitData->name) + std::to_string(i); + //std::string text = std::string("Copy##") + std::string(unit->GetUnitData()->GetName()) + std::to_string(i); - if (ImGui::Button(text.c_str())) + if (ImGui::Button("Copy")) { Utility::CopyToClipboard((uint64_t)unit); } - std::string vmtTree = std::string("VMT##") + std::string(unit->pUnitData->name) + "VMT"; + /*std::string vmtTree = std::string("VMT##") + std::string(unit->pUnitData->name) + "VMT"; if (ImGui::TreeNode(vmtTree.c_str())) { for (int vmtIndex = 0; vmtIndex < 175; vmtIndex++) @@ -150,9 +151,9 @@ void createPlayerTreeNode(Player* player, int playerIndex) } } ImGui::TreePop(); - } + }*/ - if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Building) + /*if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Building) { buildingCount++; } @@ -163,7 +164,7 @@ void createPlayerTreeNode(Player* player, int playerIndex) if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Cavalry) { calavaryCount++; - } + }*/ } } ImGui::Text("Buildings %.d", buildingCount); @@ -182,7 +183,6 @@ void Core::OnPresent() { __try { - //printf("Valid: "); MainScreen* mainScreen = Engine::Get()->GetMainScreen(); if (!mainScreen) { @@ -194,7 +194,7 @@ void Core::OnPresent() { return; } - //printf(" world %p", world); + //printf("world %p", world); PlayerArray* playerArray = world->pPlayerArray; if (!playerArray) @@ -216,7 +216,7 @@ void Core::OnPresent() for (int i = 0; i < gaiaPlayer->pObjectManager->Count; i++) { Unit* unit = gaiaPlayer->pObjectManager->units[i]; - if (!unit || unit->pUnitData->Class == -1) + if (!unit /*|| unit->GetUnitData()->Class == -1*/) { continue; } @@ -239,7 +239,7 @@ void Core::OnPresent() for (int j = 0; j < player->pObjectManager->Count; j++) { Unit* unit = player->pObjectManager->units[j]; - if (!unit || unit->pUnitData->Class == -1) + if (!unit /*|| unit->pUnitData->Class == -1*/) { continue; } diff --git a/Debug.cpp b/Debug.cpp index 5ee1f42..d86d139 100644 --- a/Debug.cpp +++ b/Debug.cpp @@ -18,9 +18,9 @@ void Debug::OnMenuMainWindow() ImGui::Separator(); ImGui::Text("Debug"); //ImGui::Text("Idle: %d", idleUnit); - if (ImGui::Button("Flare")) + if (ImGui::Button("nothing")) { - Engine::Get()->Flare(100.f, 100.f); + } ImGui::Separator(); } diff --git a/ESP.cpp b/ESP.cpp index 3cd3122..8e8b1b3 100644 --- a/ESP.cpp +++ b/ESP.cpp @@ -12,24 +12,24 @@ uint32_t ESP::colors_hex[8] = { 0xff0000ff, 0xffff0000,0xff00ff00,0xffffff00,0xf void ESP::DrawBox(Unit* unit, int32_t color, bool drawName = false) { - Vector3 one3 = unit->position; - one3.x -= unit->pUnitData->collisionX; - one3.y -= unit->pUnitData->collisionY; + Vector3 one3 = unit->GetPosition(); + one3.x -= unit->GetUnitData()->GetCollision().x; + one3.y -= unit->GetUnitData()->GetCollision().y; Vector2 one = Engine::Get()->worldToScreen(one3); - Vector3 two3 = unit->position; - two3.x += unit->pUnitData->collisionX; - two3.y += unit->pUnitData->collisionY; + Vector3 two3 = unit->GetPosition(); + two3.x += unit->GetUnitData()->GetCollision().x; + two3.y += unit->GetUnitData()->GetCollision().y; Vector2 two = Engine::Get()->worldToScreen(two3); - Vector3 three3 = unit->position; - three3.x -= unit->pUnitData->collisionX; - three3.y += unit->pUnitData->collisionY; + Vector3 three3 = unit->GetPosition(); + three3.x -= unit->GetUnitData()->GetCollision().x; + three3.y += unit->GetUnitData()->GetCollision().y; Vector2 three = Engine::Get()->worldToScreen(three3); - Vector3 four3 = unit->position; - four3.x += unit->pUnitData->collisionX; - four3.y -= unit->pUnitData->collisionY; + Vector3 four3 = unit->GetPosition(); + four3.x += unit->GetUnitData()->GetCollision().x; + four3.y -= unit->GetUnitData()->GetCollision().y; Vector2 four = Engine::Get()->worldToScreen(four3); ImVec2 ivOne = ImVec2(one.x, one.y); @@ -42,10 +42,10 @@ void ESP::DrawBox(Unit* unit, int32_t color, bool drawName = false) if (drawName) { - Vector3 textPos = unit->position; + Vector3 textPos = unit->GetPosition(); Vector2 screenTextPos = Engine::Get()->worldToScreen(textPos); ImVec2 ivTextPos = ImVec2(screenTextPos.x, screenTextPos.y); - Renderer::Get()->RenderText(unit->pUnitData->name, ivTextPos, 16, color, false); + Renderer::Get()->RenderText(std::string(unit->GetUnitData()->GetName()), ivTextPos, 16, color, false); } } @@ -84,7 +84,7 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, { static const float PI = 3.14159265358979323846f; int32_t tileSize = Engine::Get()->GetWorld()->pMap->GetTileSize(); - Vector3 center = unit->position; + Vector3 center = unit->GetPosition(); std::vector screeenPoints; @@ -106,7 +106,7 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, { Vector2 screenTextPos = Engine::Get()->worldToScreen(center); ImVec2 ivTextPos = ImVec2(screenTextPos.x, screenTextPos.y); - Renderer::Get()->RenderText(unit->pUnitData->name, ivTextPos, 16, color, false); + Renderer::Get()->RenderText(unit->GetUnitData()->GetName(), ivTextPos, 16, color, false); } } @@ -135,12 +135,12 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) { if (playerUnitEsp[playerIndex]) { - if (strcmp(unit->pUnitData->name, "FLARE") == 0) + if (strcmp(unit->GetUnitData()->GetName(), "FLARE") == 0) { return; //Dont display annoying flares that Bots use } - if (siegeImpactLocation) + /*if (siegeImpactLocation) { if (std::string(unit->pUnitData->name).find("Projectile Scorpion") != std::string::npos) { @@ -171,14 +171,15 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) Renderer::Get()->RenderCircleFilled(ImVec2(screenDestinationPos.x, screenDestinationPos.y), 30, colors_hex[*player->pColor] & 0x77ffffff); } } - } + }*/ - if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Miscellaneous) + /*if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Miscellaneous) { return; } - if (strcmp(unit->pUnitData->name, "CSTL") == 0) + */ + if (strcmp(unit->GetUnitData()->GetName(), "CSTL") == 0) { DrawBox(unit, colors_hex[*player->pColor], true); return; @@ -186,12 +187,12 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) DrawBox(unit, colors_hex[*player->pColor], playerUnitNameEsp[playerIndex]); - if (trebuchetESP && (std::string(unit->pUnitData->name).find("TREBU") != std::string::npos || std::string(unit->pUnitData->name).find("PTREB") != std::string::npos)) + if (trebuchetESP && (std::string(unit->GetUnitData()->GetName()).find("TREBU") != std::string::npos || std::string(unit->GetUnitData()->GetName()).find("PTREB") != std::string::npos)) { DrawCircle(unit, 16, colors_hex[*player->pColor], 100, 2, true); } - if (playerUnitDestinationEsp[playerIndex]) + /*if (playerUnitDestinationEsp[playerIndex]) { Vector3* targetPosition = unit->GetTargetPosition(); if (!targetPosition || targetPosition->x <= 0 || targetPosition->y <= 0) { return; } @@ -199,7 +200,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) Vector2 screenPos = Engine::Get()->worldToScreen(unit); Vector2 screenTargetPos = Engine::Get()->worldToScreen(*targetPosition); Renderer::Get()->RenderLine(ImVec2(screenPos.x, screenPos.y), ImVec2(screenTargetPos.x, screenTargetPos.y), colors_hex[*player->pColor]); - } + }*/ } } @@ -219,7 +220,7 @@ void ESP::OnNeutralUnit(Unit* unit) { if (gaiaESP || goldESP || stoneESP) { - std::string unitName = unit->pUnitData->name; + std::string unitName = unit->GetUnitData()->GetName(); Vector2 screenPos = Engine::Get()->worldToScreen(unit); if (goldESP && strcmp(unitName.c_str(), "GOLDM") == 0) @@ -290,7 +291,7 @@ void ESP::OnMenuMainWindow() { ImGui::Separator(); ImGui::Text("Siege ESP"); - ImGui::Checkbox("Siege Impact", &siegeImpactLocation); + //ImGui::Checkbox("Siege Impact", &siegeImpactLocation); ImGui::Checkbox("Trebuchet range", &trebuchetESP); ImGui::Separator(); ImGui::Text("Resource ESP"); diff --git a/Engine.cpp b/Engine.cpp index 3619af9..7f797dc 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -92,7 +92,7 @@ Vector2 Engine::worldToScreen(Vector3 position) const Vector2 Engine::worldToScreen(Unit* unit) const { - return worldToScreen(unit->position); + return worldToScreen(unit->GetPosition()); } uint32_t Engine::GetPlayerColor(int colorIndex) const @@ -249,12 +249,3 @@ void Engine::PrintBottomNotification(const char* message, unsigned int hexcolor) static tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText); fPrintBottomText(GetMainScreen()->pGameScreen, message, hexcolor, 0xffffffffffffffff); //Color format: RBGA } - -int64_t Engine::Flare(float xPos, float yPos) const -{ - typedef __int64(__fastcall* tCreateFlare) (Player* player, __int64 hundert12, __int64 zero1, __int64 zero2, float xPos, float yPos, int64_t zero3, int64_t zero4); - static tCreateFlare fCreateFlare = (tCreateFlare)(base + 0xc31270); - - return fCreateFlare(GetLocalPlayer(), 0x112, 0, 0, 220.f, 220.f, 0, 0); - //__usercall fhsCreateFlare_MAYBE_7FF718CF1270@( __int64 a3_zero@, __int64 a4_zero@, float xPos@, float yPos@, __int64 a5_zero, int a6_Zero) -} diff --git a/Engine.h b/Engine.h index ca427de..692418c 100644 --- a/Engine.h +++ b/Engine.h @@ -45,5 +45,4 @@ public: void SendChat(const char* message, bool teamchat = false) const; void PrintNotification(const char* message) const; void PrintBottomNotification(const char* message, unsigned int hexcolor) const; - int64_t Flare(float xPos, float yPos) const; }; \ No newline at end of file diff --git a/MinimapText.cpp b/MinimapText.cpp index 974558d..0153d77 100644 --- a/MinimapText.cpp +++ b/MinimapText.cpp @@ -102,7 +102,7 @@ void MinimapText::OnInitialise() { hookEnabled = &enabled; - minimapHook.Hook((BYTE*)(int64_t)GetModuleHandle(NULL) + Offsets::minimapHookOffset, (BYTE*)minimapProxy, 14); + minimapHook.Hook((BYTE*)(int64_t)GetModuleHandle(NULL) + Offsets::minimapHookOffset, (BYTE*)minimapProxy, 20); } void MinimapText::OnShutdown() diff --git a/Offsets.cpp b/Offsets.cpp index cee34de..56695f7 100644 --- a/Offsets.cpp +++ b/Offsets.cpp @@ -3,23 +3,23 @@ namespace Offsets { //48 8D 0D ? ? ? ? 41 B8 ? ? ? ? E8 ? ? ? ? 33 C0 //5 - int64_t pathfindingSystem = 0x2bb6e10; + int64_t pathfindingSystem = 0x2BB80D0; //48 8B 0D ? ? ? ? E8 ? ? ? ? C6 85 //5 - int64_t mainScreen = 0x2ba4988; + int64_t mainScreen = 0x2BA5C48; //48 8B 0D ? ? ? ? 48 85 C9 0F 84 ? ? ? ? 40 //4 - int64_t tribePanelInven = 0x2ba5ed0; + int64_t tribePanelInven = 0x2BA7190; //48 8B 83 ? ? ? ? 48 8B 48 70 F3 0F 10 //4 int64_t tribePanelInven_localPlayer = 0x208; //4C 8B 05 ? ? ? ? 45 84 - int64_t pAVGame = 0x2b96dd8; + int64_t pAVGame = 0x2B98098; //TODO %s: %d/%d //MinimapText 88 85 ? ? ? ? 41 8B 46 0C //2 - int64_t minimapHookOffset = 0xcb1646; + int64_t minimapHookOffset = 0xCB2616; //Functions int64_t printNotification = 0xca7b10; //48 83 EC 48 48 8B 05 ? ? ? ? 4C 8D //4 diff --git a/RelicManager.cpp b/RelicManager.cpp index 74d259a..db5306c 100644 --- a/RelicManager.cpp +++ b/RelicManager.cpp @@ -21,7 +21,7 @@ void RelicManager::OnMenuMainWindow() { continue; } - if (strcmp(unit->pUnitData->name, "RELIC") == 0) + if (strcmp(unit->GetUnitData()->GetName(), "RELIC") == 0) { relics.push_back(unit); } @@ -36,7 +36,7 @@ void RelicManager::OnMenuMainWindow() if (ImGui::Button("<")) { currentRelic = (currentRelic - 1) % relics.size(); - Engine::Get()->GetLocalPlayer()->SetCameraPosition(relics[currentRelic]->position); + Engine::Get()->GetLocalPlayer()->SetCameraPosition(relics[currentRelic]->GetPosition()); } ImGui::SameLine(); ImGui::Text("%d/%d", currentRelic + 1, relics.size()); @@ -44,7 +44,7 @@ void RelicManager::OnMenuMainWindow() if (ImGui::Button(">")) { currentRelic = (currentRelic + 1) % relics.size(); - Engine::Get()->GetLocalPlayer()->SetCameraPosition(relics[currentRelic]->position); + Engine::Get()->GetLocalPlayer()->SetCameraPosition(relics[currentRelic]->GetPosition()); } } ImGui::Separator(); diff --git a/Source.cpp b/Source.cpp index d6793c9..7bfb773 100644 --- a/Source.cpp +++ b/Source.cpp @@ -287,11 +287,11 @@ DWORD __stdcall InitHooks(LPVOID hModule) presentHook.Unhook(); - Sleep(1000); + Sleep(100); (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)OriginalWndProcHandler); - Sleep(1000); + Sleep(100); FreeLibraryAndExitThread((HMODULE)hModule, 0); } -- cgit v1.2.3 From ac611e09cf668329703b43c4b88bab63a3398148 Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Sat, 1 Aug 2020 14:45:52 +0200 Subject: Added support for ManualMap by removing TLS callbacks --- Classes.h | 3 +-- Core.cpp | 5 +++-- ESP.cpp | 2 +- Engine.cpp | 10 +++++----- FeatureManager.cpp | 2 -- Source.cpp | 7 ++++++- 6 files changed, 16 insertions(+), 13 deletions(-) (limited to 'Source.cpp') diff --git a/Classes.h b/Classes.h index 8f91625..a38687f 100644 --- a/Classes.h +++ b/Classes.h @@ -220,8 +220,7 @@ class Map public: int32_t GetTileSize() { - static int32_t tileOffset = 0x5B38; - return *reinterpret_cast((int64_t)this + tileOffset); + return *reinterpret_cast((int64_t)this + 0x5B38); } }; //Size=0x5CC8 diff --git a/Core.cpp b/Core.cpp index 17f0f03..74ad230 100644 --- a/Core.cpp +++ b/Core.cpp @@ -31,6 +31,9 @@ MidfunctionHook onGameStartHook = MidfunctionHook(); MidfunctionHook onTurnHook = MidfunctionHook(); MidfunctionHook onCreateUnitHook = MidfunctionHook(); + +bool openOverlay = true; + void __fastcall OnGameStartHook(Registers* registers) { FeatureManager::Get()->OnGameStart(); @@ -176,7 +179,6 @@ void createPlayerTreeNode(Player* player, int playerIndex) ImGui::PopStyleColor(); } - void Core::OnPresent() { __try @@ -202,7 +204,6 @@ void Core::OnPresent() //printf(" playerArray %p", playerArray); int64_t totalPlayers = Engine::Get()->GetTotalPlayers(); - static bool openOverlay = true; if (GetAsyncKeyState(VK_INSERT) & 1) { openOverlay = !openOverlay; } Renderer::Get()->BeginScene(); diff --git a/ESP.cpp b/ESP.cpp index 8e8b1b3..dd50c6e 100644 --- a/ESP.cpp +++ b/ESP.cpp @@ -82,7 +82,7 @@ void ESP::DrawBox(Vector3 position, Vector2 edgeSize, int32_t color) void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, float thickness = 1.f, bool drawName = false) { - static const float PI = 3.14159265358979323846f; + const float PI = 3.14159265358979323846f; int32_t tileSize = Engine::Get()->GetWorld()->pMap->GetTileSize(); Vector3 center = unit->GetPosition(); diff --git a/Engine.cpp b/Engine.cpp index bb3db2a..f59e68e 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -72,7 +72,7 @@ PlayerArray* Engine::GetPlayerArray() const Vector2 Engine::worldToScreen(Vector3 position) const { MainScreen* mainScreen = GetMainScreen(); - static int tileSize = GetWorld()->pMap->GetTileSize(); + int tileSize = GetWorld()->pMap->GetTileSize(); float tile_width = tileSize * mainScreen->pGameScreen->pMainView->ScreenPosZ; float tile_height = tileSize * mainScreen->pGameScreen->pMainView->ScreenPosZ; @@ -213,8 +213,8 @@ Player* Engine::GetLocalPlayer() const void Engine::SendChat(const char* message, bool teamchat) const { typedef void(__fastcall* tSendChat) (int64_t game, const char* text); - static tSendChat fSendChat = (tSendChat)(base + Offsets::sendChat); - static int64_t game = *(int64_t*)(base + Offsets::pAVGame); + tSendChat fSendChat = (tSendChat)(base + Offsets::sendChat); + int64_t game = *(int64_t*)(base + Offsets::pAVGame); if (teamchat) { @@ -230,13 +230,13 @@ void Engine::SendChat(const char* message, bool teamchat) const void Engine::PrintNotification(const char* message) const { typedef void(__fastcall* tPrintNotification) (GameScreen* AVGameScreen, const char* message, int unknown); - static tPrintNotification fPrintNotification = (tPrintNotification)(base + Offsets::printNotification); + tPrintNotification fPrintNotification = (tPrintNotification)(base + Offsets::printNotification); fPrintNotification(GetMainScreen()->pGameScreen, message, 0); } void Engine::PrintBottomNotification(const char* message, unsigned int hexcolor) const { typedef void(__fastcall* tPrintBottomText) (GameScreen* AVGameScreen, const char* message, unsigned int hexcolor, int64_t unused); - static tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText); + tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText); fPrintBottomText(GetMainScreen()->pGameScreen, message, hexcolor, 0xffffffffffffffff); //Color format: RBGA } diff --git a/FeatureManager.cpp b/FeatureManager.cpp index 8d9b71f..ca7cf66 100644 --- a/FeatureManager.cpp +++ b/FeatureManager.cpp @@ -22,8 +22,6 @@ FeatureManager* FeatureManager::Get() void FeatureManager::RegisterFeature(Feature* feature) { - static int feature_numer = 0; - printf("Registered feature %d\n", feature_numer++); features.push_back(feature); } diff --git a/Source.cpp b/Source.cpp index 7bfb773..045300f 100644 --- a/Source.cpp +++ b/Source.cpp @@ -24,6 +24,8 @@ ID3D11DeviceContext* pContext = nullptr; DWORD_PTR* pSwapChainVtable = nullptr; +Core* core = nullptr; + #include "main.h" //helper funcs @@ -184,7 +186,10 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval ImGui_ImplDX11_NewFrame(); ImGui::NewFrame(); - static Core* core = new Core(); + if (!core) + { + core = new Core(); + } core->OnPresent(); ImGui::EndFrame(); -- cgit v1.2.3 From 822b531a4f9b8120f1126fbaec085b8b6fab4c57 Mon Sep 17 00:00:00 2001 From: BDKPlayer Date: Sun, 2 Aug 2020 13:34:33 +0200 Subject: Added unit->GetHealth() --- Classes.h | 7 +++++++ Core.cpp | 8 +------- Source.cpp | 19 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'Source.cpp') diff --git a/Classes.h b/Classes.h index 872a627..3f05b31 100644 --- a/Classes.h +++ b/Classes.h @@ -337,6 +337,7 @@ private: int32_t position = (*reinterpret_cast((uint64_t)this + 0x3f8) - 0x17258AE0D9C58D92 ) ^ 0x78E0AFEAF822FC61; return *(float*)(&position); } + public: UnitData* GetUnitData() @@ -354,6 +355,12 @@ public: return Vector3(GetPosX(), GetPosY(), GetPosZ()); } + float GetHealth() + { + int32_t position = (*reinterpret_cast((uint64_t)this + 0x100) + 0x16F41E044E9AB282 - 0x3E3A7DDCA209C1DB); + return *(float*)(&position); + } + Vector3* GetTargetPosition() { uint64_t actionList = *reinterpret_cast((uint64_t)this + 0x648); diff --git a/Core.cpp b/Core.cpp index 74ad230..0e3163e 100644 --- a/Core.cpp +++ b/Core.cpp @@ -27,18 +27,12 @@ #include "Offsets.h" -MidfunctionHook onGameStartHook = MidfunctionHook(); MidfunctionHook onTurnHook = MidfunctionHook(); MidfunctionHook onCreateUnitHook = MidfunctionHook(); bool openOverlay = true; -void __fastcall OnGameStartHook(Registers* registers) -{ - FeatureManager::Get()->OnGameStart(); - printf("OnGameStart()\n"); -} void __fastcall OnTurnHook(Registers* registers) @@ -130,7 +124,7 @@ void createPlayerTreeNode(Player* player, int playerIndex) ImGui::Text("%p", unit); ImGui::SameLine(); ImGui::Text("%s", unit->GetUnitData()->GetName()); - ImGui::Text("%f %f %f", unit->GetPosition().x, unit->GetPosition().y, unit->GetPosition().z); + ImGui::Text("%f %f %f Health: %f", unit->GetPosition().x, unit->GetPosition().y, unit->GetPosition().z, unit->GetHealth()); ImGui::SameLine(); //std::string text = std::string("Copy##") + std::string(unit->GetUnitData()->GetName()) + std::to_string(i); diff --git a/Source.cpp b/Source.cpp index 045300f..ff17667 100644 --- a/Source.cpp +++ b/Source.cpp @@ -66,7 +66,6 @@ HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval { if (firstTime) { - printf("5\n"); firstTime = false; //only once //get device @@ -206,16 +205,16 @@ DWORD __stdcall InitHooks(LPVOID hModule) { OnDllAttach(hModule); - printf("1\n"); HMODULE hDXGIDLL = 0; do { hDXGIDLL = GetModuleHandleA("dxgi.dll"); Sleep(100); } while (!hDXGIDLL); - printf("2\n"); + IDXGISwapChain* pSwapChain; + WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, DXGIMsgProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "DX", NULL }; RegisterClassExA(&wc); HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL); @@ -269,16 +268,17 @@ DWORD __stdcall InitHooks(LPVOID hModule) return NULL; } + pSwapChainVtable = (DWORD_PTR*)pSwapChain; pSwapChainVtable = (DWORD_PTR*)pSwapChainVtable[0]; + + phookD3D11Present = (D3D11PresentHook)(DWORD_PTR*)pSwapChainVtable[8]; VmtHook presentHook = VmtHook((void**)pSwapChainVtable); - printf("3\n"); presentHook.Hook(8, hookD3D11Present); - printf("4\n"); pDevice->Release(); pContext->Release(); @@ -289,16 +289,15 @@ DWORD __stdcall InitHooks(LPVOID hModule) } FeatureManager::Get()->OnShutdown(); - + Sleep(200); + core->OnShutdown(); + Sleep(200); presentHook.Unhook(); - Sleep(100); - (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)OriginalWndProcHandler); - Sleep(100); - FreeLibraryAndExitThread((HMODULE)hModule, 0); + Sleep(100); } BOOL __stdcall DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) -- cgit v1.2.3