diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-10-30 12:26:48 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-10-30 12:26:48 +0100 |
commit | 51787d2240b8836b31e38e0590090bbb9041d8c2 (patch) | |
tree | 9d18db6661cc208a1ae4dba8097437a6a09ab39c | |
parent | f873d61f36a46c42cc444dcb596f0d354ae3d202 (diff) | |
parent | 822b531a4f9b8120f1126fbaec085b8b6fab4c57 (diff) |
Merge branch 'master' of https://github.com/simonsan/Age_of_Empires_II_Definitive-Edition-SDKHEADmaster
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | CastleManager.cpp | 16 | ||||
-rw-r--r-- | Classes.h | 114 | ||||
-rw-r--r-- | Core.cpp | 38 | ||||
-rw-r--r-- | Debug.cpp | 4 | ||||
-rw-r--r-- | ESP.cpp | 81 | ||||
-rw-r--r-- | ESP.h | 3 | ||||
-rw-r--r-- | Engine.cpp | 57 | ||||
-rw-r--r-- | Engine.h | 3 | ||||
-rw-r--r-- | FeatureManager.cpp | 2 | ||||
-rw-r--r-- | InitialiseOffsets.cpp | 6 | ||||
-rw-r--r-- | LICENSE | 1 | ||||
-rw-r--r-- | MinimapText.cpp | 2 | ||||
-rw-r--r-- | Offsets.cpp | 37 | ||||
-rw-r--r-- | Offsets.h | 1 | ||||
-rw-r--r-- | RelicManager.cpp | 6 | ||||
-rw-r--r-- | Source.cpp | 21 |
16 files changed, 235 insertions, 157 deletions
diff --git a/CastleManager.cpp b/CastleManager.cpp index 373d6e5..6b85e36 100644 --- a/CastleManager.cpp +++ b/CastleManager.cpp @@ -11,6 +11,7 @@ bool warningEnabled = true; int notification = 0; +ThreadSafeQueue<std::string> localMessages; ThreadSafeQueue<std::string> teamMessages; ThreadSafeQueue<std::string> allMessages; @@ -39,13 +40,13 @@ void CastleManager::OnUnitCreated(Unit* unit) { return; } - Player* owningPlayer = unit->pOwner; - if (!owningPlayer || owningPlayer == Engine::Get()->GetLocalPlayer()) + 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(); @@ -53,7 +54,7 @@ void CastleManager::OnUnitCreated(Unit* unit) switch (notification) { case 0: - Engine::Get()->PrintNotification(charMessage); + localMessages.push(message); break; case 1: teamMessages.push(message); @@ -69,6 +70,13 @@ void CastleManager::OnUnitCreated(Unit* unit) void CastleManager::OnMenuMainWindow() { + if (!localMessages.isEmpty()) + { + std::string message; + localMessages.pop(message); + Engine::Get()->PrintNotification(message.c_str()); + } + if (!teamMessages.isEmpty()) { std::string message; @@ -1,6 +1,7 @@ #pragma once // Generated using ReClass 2016 #include <cstdint> +#include "Engine.h" struct Vector4 { @@ -191,6 +192,29 @@ public: yScreenPos = pos.y; } + bool IsAllied(Player* other) + { + int32_t playerNumber = Engine::Get()->GetPlayerNumber(other); + int32_t* diplomacy = (int32_t*)((int64_t)this + 0xd0); + return *(diplomacy + playerNumber) == 2; + } + + bool IsEnemy(Player* other) + { + int32_t playerNumber = Engine::Get()->GetPlayerNumber(other); + int32_t* diplomacy = (int32_t*)((int64_t)this + 0xd0); + return *(diplomacy + playerNumber) == 4; + } + + bool IsNeutral(Player* other) + { + int32_t playerNumber = Engine::Get()->GetPlayerNumber(other); + int32_t* diplomacy = (int32_t*)((int64_t)this + 0xd0); + + //TODO is 0 correct? + return *(diplomacy + playerNumber) == 1; + } + }; //Size=0x93A0 class World @@ -220,8 +244,7 @@ class Map public: int32_t GetTileSize() { - static int32_t tileOffset = 0x5B38; - return *reinterpret_cast<int32_t*>((int64_t)this + tileOffset); + return *reinterpret_cast<int32_t*>((int64_t)this + 0x5B38); } }; //Size=0x5CC8 @@ -281,36 +304,67 @@ 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<char**>(*(uint64_t*)this + 0x848); + } + + Vector3 GetCollision() + { + return *(Vector3*)(*(uint64_t*)this + 0x718); + } + +}; class Unit { +private: + float GetPosX() + { + int32_t position = *reinterpret_cast<int64_t*>((uint64_t)this + 0x1a0) ^ 0x187F64ADC21CDE88 ^ 0x4F019E376DDAD1E5; + return *(float*)(&position); + } + + float GetPosY() + { + int32_t position = *reinterpret_cast<int64_t*>((uint64_t)this + 0x308) ^ 0x51E534524D81CFA6; + return *(float*)(&position); + } + + float GetPosZ() + { + int32_t position = (*reinterpret_cast<int64_t*>((uint64_t)this + 0x3f8) - 0x17258AE0D9C58D92 ) ^ 0x78E0AFEAF822FC61; + return *(float*)(&position); + } + 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. + + UnitData* GetUnitData() + { + return reinterpret_cast<UnitData*>((uint64_t)this + 0x10); + } + + Player* GetOwner() + { + return *reinterpret_cast<Player**>((uint64_t)this + 0x18); + } + + Vector3 GetPosition() + { + return Vector3(GetPosX(), GetPosY(), GetPosZ()); + } + + float GetHealth() + { + int32_t position = (*reinterpret_cast<int64_t*>((uint64_t)this + 0x100) + 0x16F41E044E9AB282 - 0x3E3A7DDCA209C1DB); + return *(float*)(&position); + } + Vector3* GetTargetPosition() { - uint64_t actionList = *reinterpret_cast<uint64_t*>((uint64_t)this + 0x288); - if (!actionList){return NULL;} + uint64_t actionList = *reinterpret_cast<uint64_t*>((uint64_t)this + 0x648); + if (!actionList) { return NULL; } uint64_t targetDataWrapper = *reinterpret_cast<uint64_t*>(actionList + 0x10); if (!targetDataWrapper) { return NULL; } uint64_t actionMoveTo = *reinterpret_cast<uint64_t*>(targetDataWrapper); @@ -318,15 +372,7 @@ public: return reinterpret_cast<Vector3*>(actionMoveTo + 0x38); } - - 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) - { - static fhsMoveToCaller moveUnitCaller = (fhsMoveToCaller)((int64_t)GetModuleHandle(NULL) + 0xc863a0); //outdated and desync - moveUnitCaller(this, 0, world, 0, xPos, yPos, 0); - } - -}; //Size=0x0250 +}; class ObjectManager { @@ -27,15 +27,12 @@ #include "Offsets.h" -MidfunctionHook onGameStartHook = MidfunctionHook(); MidfunctionHook onTurnHook = MidfunctionHook(); MidfunctionHook onCreateUnitHook = MidfunctionHook(); -void __fastcall OnGameStartHook(Registers* registers) -{ - FeatureManager::Get()->OnGameStart(); - printf("OnGameStart()\n"); -} + +bool openOverlay = true; + void __fastcall OnTurnHook(Registers* registers) @@ -85,7 +82,7 @@ Core::Core() 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()); @@ -93,7 +90,6 @@ Core::Core() featureManager->RegisterFeature(new MinimapText()); featureManager->RegisterFeature(new RelicManager()); featureManager->RegisterFeature(new CustomLoadingScreen("C:\\wallpaper.jpg")); - //featureManager->RegisterFeature(new PauseManager()); featureManager->RegisterFeature(new CastleManager()); #ifdef _DEBUG @@ -123,19 +119,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 Health: %f", unit->GetPosition().x, unit->GetPosition().y, unit->GetPosition().z, unit->GetHealth()); 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++) @@ -149,9 +146,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++; } @@ -162,7 +159,7 @@ void createPlayerTreeNode(Player* player, int playerIndex) if (unit->pUnitData->Class == (int16_t)EnumUnitDataClass::Cavalry) { calavaryCount++; - } + }*/ } } ImGui::Text("Buildings %.d", buildingCount); @@ -176,12 +173,10 @@ void createPlayerTreeNode(Player* player, int playerIndex) ImGui::PopStyleColor(); } - void Core::OnPresent() { __try { - //printf("Valid: "); MainScreen* mainScreen = Engine::Get()->GetMainScreen(); if (!mainScreen) { @@ -193,7 +188,7 @@ void Core::OnPresent() { return; } - //printf(" world %p", world); + //printf("world %p", world); PlayerArray* playerArray = world->pPlayerArray; if (!playerArray) @@ -203,7 +198,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(); @@ -215,7 +209,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; } @@ -238,7 +232,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; } @@ -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(); } @@ -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); } } @@ -82,9 +82,9 @@ 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->position; + Vector3 center = unit->GetPosition(); std::vector<ImVec2> screeenPoints; @@ -101,12 +101,12 @@ void ESP::DrawCircle(Unit* unit, int radius, int32_t color, int smoothness = 16, { Renderer::Get()->RenderLine(screeenPoints[i], screeenPoints[i - 1], color, thickness); } - Renderer::Get()->RenderLine(screeenPoints[0], screeenPoints[screeenPoints.size()-1], color, thickness); + Renderer::Get()->RenderLine(screeenPoints[0], screeenPoints[screeenPoints.size() - 1], color, thickness); if (drawName) { 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); } } @@ -117,7 +117,7 @@ void ESP::LoadConfig() trebuchetESP = config->ReadInt("ESP", "trebuchetESP"); gaiaESP = config->ReadInt("ESP", "gaiaESP"); goldESP = config->ReadInt("ESP", "goldESP"); - stoneESP = config->ReadInt("ESP", "stoneESP"); + stoneESP = config->ReadInt("ESP", "stoneESP"); } void ESP::SaveConfig() @@ -135,14 +135,28 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) { if (playerUnitEsp[playerIndex]) { - if (strcmp(unit->pUnitData->name, "FLARE") == 0) + if (!allyEsp && Engine::Get()->GetLocalPlayer()->IsAllied(player)) + { + return; + } + + if (!neutralEsp && Engine::Get()->GetLocalPlayer()->IsNeutral(player)) + { + return; + } + + if (!enemyEsp && Engine::Get()->GetLocalPlayer()->IsEnemy(player)) + { + return; + } + if (strcmp(unit->GetUnitData()->GetName(), "FLARE") == 0) { return; //Dont display annoying flares that Bots use } if (siegeImpactLocation) { - if (std::string(unit->pUnitData->name).find("Projectile Scorpion") != std::string::npos) + if (std::string(unit->GetUnitData()->GetName()).find("Projectile Scorpion") != std::string::npos) { Vector3* destination = unit->GetTargetPosition(); if (destination) @@ -152,7 +166,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) } } - if (std::string(unit->pUnitData->name).find("Projectile Mangonel") != std::string::npos) + if (std::string(unit->GetUnitData()->GetName()).find("Projectile Mangonel") != std::string::npos) { Vector3* destination = unit->GetTargetPosition(); if (destination) @@ -162,7 +176,7 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) } } - if (std::string(unit->pUnitData->name).find("Projectile Trebuchet") != std::string::npos) + if (std::string(unit->GetUnitData()->GetName()).find("Projectile Trebuchet") != std::string::npos) { Vector3* destination = unit->GetTargetPosition(); if (destination) @@ -173,12 +187,12 @@ void ESP::OnUnitIteration(Unit* unit, Player* player, int playerIndex) } } - 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,7 +200,7 @@ 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); } @@ -219,7 +233,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) @@ -277,7 +291,7 @@ void ESP::OnNeutralUnit(Unit* unit) Renderer::Get()->RenderText(unitName, ImVec2(screenPos.x, screenPos.y), 16, 0xffffffff); return; } - + if (strcmp(unitName.c_str(), "RELIC") == 0) { Renderer::Get()->RenderCircleFilled(ImVec2(screenPos.x, screenPos.y), 50, 0x40ffffff); @@ -289,8 +303,15 @@ void ESP::OnNeutralUnit(Unit* unit) void ESP::OnMenuMainWindow() { ImGui::Separator(); + ImGui::Text("Diplomacy ESP"); + ImGui::Checkbox("Ally", &allyEsp); + ImGui::SameLine(); + ImGui::Checkbox("Neutral", &neutralEsp); + ImGui::SameLine(); + ImGui::Checkbox("Enemy", &enemyEsp); + 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"); @@ -12,6 +12,9 @@ class ESP : public Feature bool stoneESP = true; bool trebuchetESP = true; bool siegeImpactLocation = true; + bool allyEsp = false; + bool neutralEsp = true; + bool enemyEsp = true; bool playerUnitEsp[9] = { true,true,true,true,true,true,true,true, true }; bool playerUnitDestinationEsp[9] = { false,false,false,false,false,false,false,false, false }; @@ -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; @@ -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 @@ -162,6 +162,31 @@ Player* Engine::GetPlayer(int index) const return playerArray->playerData[index].player; } +//TODO is this stable? +int Engine::GetPlayerNumber(Player* player) +{ + const int64_t totalPlayers = GetTotalPlayers(); + + + MainScreen* mainScreen = GetMainScreen(); + + World* main = GetWorld(); + + PlayerArray* playerArray = main->pPlayerArray; + + + for (int i = 0; i <= totalPlayers; i++) + { + if (playerArray->playerData[i].player == player) + { + return i; + } + } + + printf("Failed to GetPlayerNumber()\n"); + return -1; +} + Player* Engine::GetPlayerByName(char* playerName) const { MainScreen* mainScreen = GetMainScreen(); @@ -209,21 +234,12 @@ Player* Engine::GetLocalPlayer() const } // -//Pauses the game -void Engine::PauseGame() const -{ - typedef int64_t(__fastcall* tPauseGame)(CommHandler* CommHandler); - static tPauseGame fPauseGame = (tPauseGame)(base + Offsets::pauseGame); - fPauseGame(Get()->GetGame()->pCommHandler); -} - -// //Sends a chat message. Only to be called from rendering thread 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) { @@ -239,22 +255,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); - fPrintNotification(GetMainScreen()->pGameScreen, message, 1); + 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 } - -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@<rax>( __int64 a3_zero@<r8>, __int64 a4_zero@<r9>, float xPos@<xmm2>, float yPos@<xmm3>, __int64 a5_zero, int a6_Zero) -} @@ -38,12 +38,11 @@ public: uint32_t GetPlayerColor(int colorIndex) const; ImVec4 GetPlayerColorImGUI(int colorIndex) const; Player* GetPlayer(int index) const; + int GetPlayerNumber(Player* player); Player* GetPlayerByName(char* playername) const; Player* GetLocalPlayer() const; - void PauseGame() const; 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/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/InitialiseOffsets.cpp b/InitialiseOffsets.cpp index 4611db8..d626897 100644 --- a/InitialiseOffsets.cpp +++ b/InitialiseOffsets.cpp @@ -57,11 +57,7 @@ void InitialiseOffsets::OnInitialise() printBottomText = Pattern::FindSignature("AoE2DE_s.exe", "48 8B C4 48 83 EC 78 F3 0F 10 05 ? ? ? ? 41"); printBottomText -= base; printf("printBottomText: %x\n", printBottomText); - - pauseGame = Pattern::FindSignature("AoE2DE_s.exe", "48 89 5C 24 ? 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 80"); - pauseGame -= base; - printf("pauseGame: %x\n", pauseGame); - + sendChat = Pattern::FindSignature("AoE2DE_s.exe", "E8 ? ? ? ? 90 48 8B 05 ? ? ? ? F2") - 0x94; sendChat -= base; printf("sendChat: %x\n", sendChat); @@ -671,4 +671,3 @@ into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -<https://www.gnu.org/licenses/why-not-lgpl.html>. 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 7a568ab..129d0bf 100644 --- a/Offsets.cpp +++ b/Offsets.cpp @@ -2,39 +2,38 @@ namespace Offsets { - //48 8D 0D ? ? ? ? 41 B8 ? ? ? ? E8 ? ? ? ? 33 C0 //4 - //48 8D 0D ? ? ? ? E8 ? ? ? ? 0F B6 C0 //4 - int64_t pathfindingSystem = 0x29A3AE0; + //48 8D 0D ? ? ? ? 41 B8 ? ? ? ? E8 ? ? ? ? 33 C0 //5 + int64_t pathfindingSystem = 0x2BB80D0; - //48 8B 0D ? ? ? ? E8 ? ? ? ? C6 85 //4 - int64_t mainScreen = 0x2991980; + //48 8B 0D ? ? ? ? E8 ? ? ? ? C6 85 //5 + int64_t mainScreen = 0x2BA5C48; - //48 8B 0D ? ? ? ? 48 85 C9 0F 84 ? ? ? ? 40 //3 - int64_t tribePanelInven = 0x2992EE0; + //48 8B 0D ? ? ? ? 48 85 C9 0F 84 ? ? ? ? 40 //4 + int64_t tribePanelInven = 0x2BA7190; - //48 8B 83 ? ? ? ? 48 8B 48 70 F3 0F 10 //3 + //48 8B 83 ? ? ? ? 48 8B 48 70 F3 0F 10 //4 int64_t tribePanelInven_localPlayer = 0x208; - //49 83 BF ? ? ? ? ? 0F 86 ? ? ? ? 48 8B + 0xE - int64_t pAVGame = 0x2983AD0; + //4C 8B 05 ? ? ? ? 45 84 + int64_t pAVGame = 0x2B98098; + //TODO %s: %d/%d //MinimapText 88 85 ? ? ? ? 41 8B 46 0C //2 - int64_t minimapHookOffset = 0xc26e49; + int64_t minimapHookOffset = 0xCB2616; //Functions - int64_t printNotification = 0xc1d320; //48 83 EC 48 48 8B 05 ? ? ? ? 4C 8D //3 - int64_t printBottomText = 0xc0c680; //48 8B C4 48 83 EC 78 F3 0F 10 05 ? ? ? ? 41 //3 - int64_t pauseGame = 0x81ddd0; //48 89 5C 24 ? 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 80 //2 + int64_t printNotification = 0xCA8AC0; //48 83 EC 48 48 8B 05 ? ? ? ? 4C 8D //4 + int64_t printBottomText = 0xc92480; //48 8B C4 48 83 EC 78 F3 0F 10 05 ? ? ? ? 41 //4 - //E8 ? ? ? ? 90 48 8B 05 ? ? ? ? F2 - 0x94 //0 - int64_t sendChat = 0x9AC090; + //E8 ? ? ? ? 90 48 8B 05 ? ? ? ? F2 - 0x94 //1 + int64_t sendChat = 0xa16090; - int64_t createUnitHook = 0xE06260; //48 89 5C 24 ? 48 89 6C 24 ? 57 48 83 EC 20 8B 41 //2 + int64_t createUnitHook = 0xeadf40; //48 89 5C 24 ? 48 89 6C 24 ? 57 48 83 EC 20 8B 41 //4 int64_t playerArrayStart = 0x2a8; //Manual Update //CustomLoadingScreen - int64_t pathToLoadScreen = 0x1E72D20; // /resources/loading_slash.png - int64_t loadPathToLoadScreen = 0xEEA8EE; // x-ref /resources/loading_slash.png + int64_t pathToLoadScreen = 0x2013488; // /resources/loading_slash.png + int64_t loadPathToLoadScreen = 0xfe1ece; // x-ref /resources/loading_slash.png }
\ No newline at end of file @@ -18,7 +18,6 @@ namespace Offsets //Functions extern int64_t printNotification; extern int64_t printBottomText; - extern int64_t pauseGame; extern int64_t sendChat; extern int64_t createUnitHook; 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(); @@ -24,6 +24,8 @@ ID3D11DeviceContext* pContext = nullptr; DWORD_PTR* pSwapChainVtable = nullptr; +Core* core = nullptr; + #include "main.h" //helper funcs @@ -183,7 +185,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(); @@ -209,6 +214,7 @@ DWORD __stdcall InitHooks(LPVOID hModule) 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); @@ -262,12 +268,16 @@ 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); + presentHook.Hook(8, hookD3D11Present); pDevice->Release(); @@ -279,16 +289,15 @@ DWORD __stdcall InitHooks(LPVOID hModule) } FeatureManager::Get()->OnShutdown(); - + Sleep(200); + core->OnShutdown(); + Sleep(200); presentHook.Unhook(); - Sleep(1000); - (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)OriginalWndProcHandler); - Sleep(1000); - FreeLibraryAndExitThread((HMODULE)hModule, 0); + Sleep(100); } BOOL __stdcall DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) |