forked from kubik-jaroslav/ddda-dinput8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortcrystals.cpp
More file actions
78 lines (70 loc) · 2.06 KB
/
Copy pathPortcrystals.cpp
File metadata and controls
78 lines (70 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "stdafx.h"
#include "Portcrystals.h"
LPVOID oMapClosest, oMapCursor;
float pMapClosest[3] = { 0 }, pMapCursor[3] = { 0 };
void __declspec(naked) HMapClosest()
{
__asm mov edx, [eax];
__asm mov dword ptr[pMapClosest], edx;
__asm mov edx, [eax + 4];
__asm mov dword ptr[pMapClosest + 4], edx;
__asm mov edx, [eax + 8];
__asm mov dword ptr[pMapClosest + 8], edx;
__asm jmp oMapClosest;
}
void __declspec(naked) HMapCursor()
{
__asm mov edx, [esi + 0x8D0];
__asm mov dword ptr[pMapCursor], edx;
__asm mov edx, [esi + 0x8D4];
__asm mov dword ptr[pMapCursor + 4], edx;
__asm mov edx, [esi + 0x8D8];
__asm mov dword ptr[pMapCursor + 8], edx;
__asm jmp oMapCursor;
}
void renderPortcrystalsPos(const char *label, float *pPosition)
{
float v[3] = { pPosition[0], pPosition[2], pPosition[1] };
ImGui::InputFloat3(label, v, 0, ImGuiInputTextFlags_ReadOnly);
}
void renderPortcrystalsUI()
{
if (ImGui::CollapsingHeader("Portcrystals"))
{
renderPortcrystalsPos("Cursor", pMapCursor);
renderPortcrystalsPos("Closest", pMapClosest);
ImGui::Separator();
for (int i = 0; i < 10; i++)
{
ImGui::PushID(i);
float *pPosition = GetBasePtr<float>(0xBE3A0 + 16 * i);
renderPortcrystalsPos("##p", pPosition);
ImGui::SameLine();
if (ImGui::Button("Cursor"))
{
pPosition[0] = pMapCursor[0];
pPosition[1] = pMapCursor[1];
pPosition[2] = pMapCursor[2];
}
ImGui::SameLine();
if (ImGui::Button("Closest"))
{
pPosition[0] = pMapClosest[0];
pPosition[1] = pMapClosest[1];
pPosition[2] = pMapClosest[2];
}
ImGui::PopID();
}
}
}
void Hooks::Portcrystals()
{
BYTE *pOffset;
BYTE sig1[] = { 0xE8, 0xCC, 0xCC, 0xCC, 0xCC, 0x8B, 0x86, 0x94, 0x02, 0x00, 0x00, 0x83, 0xF8, 0x41, 0x7C };
if (FindSignature("Portcrystals", sig1, &pOffset))
CreateHook("Portcrystals", pOffset + 5, &HMapClosest, &oMapClosest);
BYTE sig2[] = { 0xD9, 0x86, 0xD0, 0x08, 0x00, 0x00, 0x57 };
if (FindSignature("Portcrystals", sig2, &pOffset))
CreateHook("Portcrystals", pOffset, &HMapCursor, &oMapCursor);
InGameUIAdd(renderPortcrystalsUI);
}