aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBDKPlayer <fabian.stotz@yahoo.de>2020-06-04 12:50:01 +0200
committerBDKPlayer <fabian.stotz@yahoo.de>2020-06-04 12:50:01 +0200
commit35f1e21263097bf044a866817bdeeff7da651f77 (patch)
tree281075620c829eae30277126eade94cbb9b68c4e
parente441b54d5d7cff7115831f0e3cb21e98d9124a37 (diff)
Added pattern scanning
-rw-r--r--AoE_imgui_DE.vcxproj4
-rw-r--r--AoE_imgui_DE.vcxproj.filters12
-rw-r--r--Classes.h2
-rw-r--r--Core.cpp2
-rw-r--r--CustomLoadingScreen.cpp5
-rw-r--r--CustomLoadingScreen.h1
-rw-r--r--Engine.cpp2
-rw-r--r--InitialiseOffsets.cpp77
-rw-r--r--InitialiseOffsets.h11
-rw-r--r--Offsets.cpp8
-rw-r--r--Offsets.h9
-rw-r--r--Pattern.cpp68
-rw-r--r--Pattern.h9
-rw-r--r--RelicManager.cpp2
14 files changed, 202 insertions, 10 deletions
diff --git a/AoE_imgui_DE.vcxproj b/AoE_imgui_DE.vcxproj
index 4b8491a..11110a3 100644
--- a/AoE_imgui_DE.vcxproj
+++ b/AoE_imgui_DE.vcxproj
@@ -167,12 +167,14 @@
<ClInclude Include="imgui\imstb_rectpack.h" />
<ClInclude Include="imgui\imstb_textedit.h" />
<ClInclude Include="imgui\imstb_truetype.h" />
+ <ClInclude Include="InitialiseOffsets.h" />
<ClInclude Include="main.h" />
<ClInclude Include="MidfunctionHook.h" />
<ClInclude Include="MinimapText.h" />
<ClInclude Include="Offsets.h" />
<ClInclude Include="OneVsOne.h" />
<ClInclude Include="Patcher.h" />
+ <ClInclude Include="Pattern.h" />
<ClInclude Include="RelicManager.h" />
<ClInclude Include="Renderer.h" />
<ClInclude Include="ResourceInformation.h" />
@@ -197,11 +199,13 @@
<ClCompile Include="imgui\imgui_impl_dx11.cpp" />
<ClCompile Include="imgui\imgui_impl_win32.cpp" />
<ClCompile Include="imgui\imgui_widgets.cpp" />
+ <ClCompile Include="InitialiseOffsets.cpp" />
<ClCompile Include="MidfunctionHook.cpp" />
<ClCompile Include="MinimapText.cpp" />
<ClCompile Include="Offsets.cpp" />
<ClCompile Include="OneVsOne.cpp" />
<ClCompile Include="Patcher.cpp" />
+ <ClCompile Include="Pattern.cpp" />
<ClCompile Include="RelicManager.cpp" />
<ClCompile Include="Renderer.cpp" />
<ClCompile Include="ResourceInformation.cpp" />
diff --git a/AoE_imgui_DE.vcxproj.filters b/AoE_imgui_DE.vcxproj.filters
index 1fd3bbb..d994a0d 100644
--- a/AoE_imgui_DE.vcxproj.filters
+++ b/AoE_imgui_DE.vcxproj.filters
@@ -76,6 +76,12 @@
<ClCompile Include="FeatureManager.cpp">
<Filter>source\features</Filter>
</ClCompile>
+ <ClCompile Include="Pattern.cpp">
+ <Filter>source\util</Filter>
+ </ClCompile>
+ <ClCompile Include="InitialiseOffsets.cpp">
+ <Filter>source\features</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Classes.h">
@@ -171,6 +177,12 @@
<ClInclude Include="Utility.h">
<Filter>header\util</Filter>
</ClInclude>
+ <ClInclude Include="Pattern.h">
+ <Filter>header\util</Filter>
+ </ClInclude>
+ <ClInclude Include="InitialiseOffsets.h">
+ <Filter>header\features</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="header">
diff --git a/Classes.h b/Classes.h
index 8a64ba3..6f4e3fe 100644
--- a/Classes.h
+++ b/Classes.h
@@ -322,7 +322,7 @@ public:
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);
+ static fhsMoveToCaller moveUnitCaller = (fhsMoveToCaller)((int64_t)GetModuleHandle(NULL) + 0xc863a0); //outdated and desync
moveUnitCaller(this, 0, world, 0, xPos, yPos, 0);
}
diff --git a/Core.cpp b/Core.cpp
index aade39e..ccb8dcc 100644
--- a/Core.cpp
+++ b/Core.cpp
@@ -23,6 +23,7 @@
#include "CustomLoadingScreen.h"
#include "Debug.h"
//#include "PauseManager.h"
+#include "InitialiseOffsets.h"
#include "Offsets.h"
@@ -84,6 +85,7 @@ Core::Core()
onCreateUnitHook.Hook((BYTE*)GetModuleHandle(NULL) + Offsets::createUnitHook, (BYTE*)OnCreateUnitHook, 15);
FeatureManager* featureManager = FeatureManager::Get();
+ featureManager->RegisterFeature(new InitialiseOffsets());
//Register Features here
featureManager->RegisterFeature(new ResourceInformation());
diff --git a/CustomLoadingScreen.cpp b/CustomLoadingScreen.cpp
index 0e380f6..ae7a302 100644
--- a/CustomLoadingScreen.cpp
+++ b/CustomLoadingScreen.cpp
@@ -1,6 +1,7 @@
#include "CustomLoadingScreen.h"
#include "Patcher.h"
+#include "Offsets.h"
CustomLoadingScreen::CustomLoadingScreen(char* imagePath)
@@ -11,10 +12,10 @@ CustomLoadingScreen::CustomLoadingScreen(char* imagePath)
void CustomLoadingScreen::OnInitialise()
{
//original string "/resources/loading_slash.png"
- Patcher().Patch((BYTE*)GetModuleHandle(NULL) + 0x1E72D20,(int64_t)this->imagePath);
+ Patcher().Patch((BYTE*)GetModuleHandle(NULL) + Offsets::pathToLoadScreen,(int64_t)this->imagePath);
//change LEA to MOV by changing 0x8d to 0x8b
- Patcher().Patch((BYTE*)GetModuleHandle(NULL) + 0xEEA8EE + 1, (int8_t)0x8b);
+ Patcher().Patch((BYTE*)GetModuleHandle(NULL) + Offsets::loadPathToLoadScreen + 1, (int8_t)0x8b);
}
void CustomLoadingScreen::OnMenuMainWindow()
diff --git a/CustomLoadingScreen.h b/CustomLoadingScreen.h
index 21f1eaa..dcfc04c 100644
--- a/CustomLoadingScreen.h
+++ b/CustomLoadingScreen.h
@@ -1,5 +1,4 @@
#pragma once
-#pragma once
#include "Feature.h"
class CustomLoadingScreen : public Feature
diff --git a/Engine.cpp b/Engine.cpp
index 43f8a59..e1b38cc 100644
--- a/Engine.cpp
+++ b/Engine.cpp
@@ -49,7 +49,7 @@ int Engine::GetTotalPlayers() const
{
return 0;
}
- return (*(int64_t*)((int64_t)world + 0x2b0) - *(int64_t*)((int64_t)world + 0x2a8)) / 0x10;
+ return (*(int64_t*)((int64_t)world + Offsets::playerArrayStart + 0x8) - *(int64_t*)((int64_t)world + Offsets::playerArrayStart)) / 0x10;
}
PlayerArray* Engine::GetPlayerArray() const
diff --git a/InitialiseOffsets.cpp b/InitialiseOffsets.cpp
new file mode 100644
index 0000000..4611db8
--- /dev/null
+++ b/InitialiseOffsets.cpp
@@ -0,0 +1,77 @@
+#include "InitialiseOffsets.h"
+
+
+#include "Pattern.h"
+#include "Offsets.h"
+
+#include <Windows.h>
+
+void InitialiseOffsets::OnInitialise()
+{
+ using namespace Offsets;
+
+
+ printf("~~ Initialising Offsets ~~\n");
+
+ uint64_t base = (uint64_t)GetModuleHandle(NULL);
+
+ pathfindingSystem = Pattern::FindSignature("AoE2DE_s.exe", "48 8D 0D ? ? ? ? 41 B8 ? ? ? ? E8 ? ? ? ? 33 C0");
+ pathfindingSystem += *(uint32_t*)(pathfindingSystem + 3) + 7;
+ pathfindingSystem -= base;
+ printf("pathfindingSystem: %x\n", pathfindingSystem);
+
+ mainScreen = Pattern::FindSignature("AoE2DE_s.exe", "48 8B 0D ? ? ? ? E8 ? ? ? ? C6 85");
+ mainScreen += *(uint32_t*)(mainScreen + 3) + 7;
+ mainScreen -= base;
+ printf("mainScreen: %x\n", mainScreen);
+
+ tribePanelInven = Pattern::FindSignature("AoE2DE_s.exe", "48 8B 0D ? ? ? ? 48 85 C9 0F 84 ? ? ? ? 40");
+ tribePanelInven += *(uint32_t*)(tribePanelInven + 3) + 7;
+ tribePanelInven -= base;
+ printf("tribePanelInven: %x\n", tribePanelInven);
+
+ tribePanelInven_localPlayer = Pattern::FindSignature("AoE2DE_s.exe", "48 8B 83 ? ? ? ? 48 8B 48 70 F3 0F 10");
+ tribePanelInven_localPlayer = *(uint32_t*)(tribePanelInven_localPlayer + 3);
+ tribePanelInven_localPlayer -= base;
+ printf("tribePanelInven_localPlayer: %x\n", tribePanelInven_localPlayer);
+
+ playerArrayStart = Pattern::FindSignature("AoE2DE_s.exe", "48 8B 88 ? ? ? ? 8B 83 ? ? ? ? 48 8B 0C");
+ playerArrayStart = *(int32_t*)(playerArrayStart + 3);
+ printf("playerArrayStart: %x\n", playerArrayStart);
+
+ pAVGame = Pattern::FindSignature("AoE2DE_s.exe", "49 83 BF ? ? ? ? ? 0F 86 ? ? ? ? 48 8B") + 0xE;
+ pAVGame += *(uint32_t*)(pAVGame + 3) + 7;
+ pAVGame -= base;
+ printf("pAVGame: %x\n", pAVGame);
+
+
+ minimapHookOffset = Pattern::FindSignature("AoE2DE_s.exe", "88 85 ? ? ? ? 41 8B 46 0C");
+ minimapHookOffset -= base;
+ printf("minimapHookOffset: %x\n", minimapHookOffset);
+
+ //Functions
+ printNotification = Pattern::FindSignature("AoE2DE_s.exe", "48 83 EC 48 48 8B 05 ? ? ? ? 4C 8D");
+ printNotification -= base;
+ printf("printNotification: %x\n", printNotification);
+
+ 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);
+
+
+ createUnitHook = Pattern::FindSignature("AoE2DE_s.exe", "48 89 74 24 ? B8 ? ? ? ? 4C 89 74") - 0x23;
+ createUnitHook -= base;
+ printf("createUnitHook: %x\n", createUnitHook);
+
+
+
+ printf("~~~~~~~~~~~~~~~\n");
+} \ No newline at end of file
diff --git a/InitialiseOffsets.h b/InitialiseOffsets.h
new file mode 100644
index 0000000..62862e2
--- /dev/null
+++ b/InitialiseOffsets.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "Feature.h"
+
+class InitialiseOffsets : public Feature
+{
+
+public:
+
+ //Callbacks
+ void OnInitialise() override;
+}; \ No newline at end of file
diff --git a/Offsets.cpp b/Offsets.cpp
index 67c2d9f..7a568ab 100644
--- a/Offsets.cpp
+++ b/Offsets.cpp
@@ -15,7 +15,7 @@ namespace Offsets
//48 8B 83 ? ? ? ? 48 8B 48 70 F3 0F 10 //3
int64_t tribePanelInven_localPlayer = 0x208;
- //49 83 BF ? ? ? ? ? 0F 86 ? ? ? ? 48 8B - 0xE
+ //49 83 BF ? ? ? ? ? 0F 86 ? ? ? ? 48 8B + 0xE
int64_t pAVGame = 0x2983AD0;
//MinimapText 88 85 ? ? ? ? 41 8B 46 0C //2
@@ -31,4 +31,10 @@ namespace Offsets
int64_t createUnitHook = 0xE06260; //48 89 5C 24 ? 48 89 6C 24 ? 57 48 83 EC 20 8B 41 //2
+ 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
} \ No newline at end of file
diff --git a/Offsets.h b/Offsets.h
index ff28e5f..74edc51 100644
--- a/Offsets.h
+++ b/Offsets.h
@@ -8,12 +8,11 @@ namespace Offsets
extern int64_t totalPlayers;
extern int64_t pausesLeft;
extern int64_t pAVGame;
+ extern int64_t playerArrayStart;
extern int64_t tribePanelInven;
extern int64_t tribePanelInven_localPlayer;
- //extern int64_t unit_actionlist ;
-
extern int64_t minimapHookOffset;
//Functions
@@ -22,4 +21,8 @@ namespace Offsets
extern int64_t pauseGame;
extern int64_t sendChat;
extern int64_t createUnitHook;
-} \ No newline at end of file
+
+ //CustomLoadingScreen
+ extern int64_t pathToLoadScreen;
+ extern int64_t loadPathToLoadScreen;
+}
diff --git a/Pattern.cpp b/Pattern.cpp
new file mode 100644
index 0000000..9aca68a
--- /dev/null
+++ b/Pattern.cpp
@@ -0,0 +1,68 @@
+#include "Pattern.h"
+
+#include <Windows.h>
+#include <psapi.h>
+#include <tlhelp32.h>
+#include <iostream>
+
+//uint64_t Pattern::FindSignature(const char* szModule, const char* szSignature)
+//{
+// printf("Start FindSig\n");
+// //CREDITS: learn_more
+//#define INRANGE(x,a,b) (x >= a && x <= b)
+//#define getBits( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0))
+//#define getByte( x ) (getBits(x[0]) << 4 | getBits(x[1]))
+//
+// MODULEINFO modInfo;
+// GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(szModule), &modInfo, sizeof(MODULEINFO));
+//
+// printf("GetModuleInformation\n");
+//
+// DWORD startAddress = (DWORD)modInfo.lpBaseOfDll;
+// DWORD endAddress = startAddress + modInfo.SizeOfImage;
+// const char* pat = szSignature;
+// DWORD firstMatch = 0;
+// printf("BeforeLoop\n");
+// for (DWORD pCur = startAddress; pCur < endAddress; pCur++) {
+// if (!*pat) return firstMatch;
+// if (*(PBYTE)pat == '\?' || *(BYTE*)pCur == getByte(pat)) {
+// if (!firstMatch) firstMatch = pCur;
+// if (!pat[2]) return firstMatch;
+// if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') pat += 3;
+// else pat += 2; //one ?
+// }
+// else {
+// pat = szSignature;
+// firstMatch = 0;
+// }
+// }
+// return NULL;
+//}
+
+uint64_t Pattern::FindSignature(const char* szModule, const char* szSignature)
+{
+#define INRANGE(x,a,b) (x >= a && x <= b)
+#define GET_BYTE( x ) (GET_BITS(x[0]) << 4 | GET_BITS(x[1]))
+#define GET_BITS( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0))
+
+ MODULEINFO modInfo;
+ GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(szModule), &modInfo, sizeof(MODULEINFO));
+ uint64_t startAddress = (uint64_t)GetModuleHandleA(szModule);
+ uint64_t endAddress = (startAddress + (uint64_t)modInfo.SizeOfImage);
+ const char* pat = szSignature;
+ uint64_t firstMatch = 0;
+ for (uint64_t pCur = startAddress; pCur < endAddress; pCur++) {
+ if (!*pat) return firstMatch;
+ if (*(PBYTE)pat == ('\?') || *(BYTE*)pCur == GET_BYTE(pat)) {
+ if (!firstMatch) firstMatch = pCur;
+ if (!pat[2]) return firstMatch;
+ if (*(PWORD)pat == ('\?\?') || *(PBYTE)pat != ('\?')) pat += 3;
+ else pat += 2;
+ }
+ else {
+ pat = szSignature;
+ firstMatch = 0;
+ }
+ }
+ return NULL;
+}
diff --git a/Pattern.h b/Pattern.h
new file mode 100644
index 0000000..50aa721
--- /dev/null
+++ b/Pattern.h
@@ -0,0 +1,9 @@
+#pragma once
+#include <cstdint>
+
+
+class Pattern
+{
+public:
+ static uint64_t FindSignature(const char* szModule, const char* szSignature);
+}; \ No newline at end of file
diff --git a/RelicManager.cpp b/RelicManager.cpp
index 1489481..74d259a 100644
--- a/RelicManager.cpp
+++ b/RelicManager.cpp
@@ -10,7 +10,7 @@ void RelicManager::OnNeutralUnit(Unit* unit)
void RelicManager::OnMenuMainWindow()
{
- if (true) //TODO Need OnGameStart()
+ if (true)
{
relics.clear();
Player* gaia = Engine::Get()->GetPlayerByName("Gaia");