aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBDKPlayer <fabian.stotz@yahoo.de>2020-08-02 13:34:33 +0200
committerBDKPlayer <fabian.stotz@yahoo.de>2020-08-02 13:34:33 +0200
commit822b531a4f9b8120f1126fbaec085b8b6fab4c57 (patch)
tree270cb36ceca218fcfe1e3cbb9f8b9cf3127602bb
parenta927cae5522db4eadc250a6cda03494f7a8c2a83 (diff)
Added unit->GetHealth()
-rw-r--r--Classes.h7
-rw-r--r--Core.cpp8
-rw-r--r--Source.cpp19
3 files changed, 17 insertions, 17 deletions
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<int64_t*>((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<int64_t*>((uint64_t)this + 0x100) + 0x16F41E044E9AB282 - 0x3E3A7DDCA209C1DB);
+ return *(float*)(&position);
+ }
+
Vector3* GetTargetPosition()
{
uint64_t actionList = *reinterpret_cast<uint64_t*>((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)