Repository navigation
Expand file tree
/
Copy pathmisc.cpp
More file actions
86 lines (75 loc) · 2.3 KB
/
Copy pathmisc.cpp
File metadata and controls
86 lines (75 loc) · 2.3 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
79
80
81
82
83
84
85
86
#include "misc.h"
#include "GameState.h"
#include "main.h"
#include <windows.h>
namespace MemoryHelpers
{
bool SafeRead4Bytes(uintptr_t address, int32_t* outInt, float* outFloat)
{
__try
{
*outInt = *reinterpret_cast<int32_t*>(address);
*outFloat = *reinterpret_cast<float*>(address);
return true;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
}
bool SafeCopyMemory(void* destination, void* source, size_t size)
{
if (!source || !destination || size <= 0) return false;
__try
{
memcpy(destination, source, size);
return true;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
}
};
void PressKey(char key)
{
HWND gameWindow = FindWindowA("UnrealWindow", "Marbles On Stream");
if (!gameWindow)
{
gameWindow = FindWindowA("UnrealWindow", NULL); // Fallback
}
if (gameWindow)
{
UINT scanCode = MapVirtualKeyA(key, MAPVK_VK_TO_VSC);
// Construct the exact 32-bit lParam that Unreal Engine requires
LPARAM lParamDown = 1 | (scanCode << 16);
LPARAM lParamUp = 1 | (scanCode << 16) | (1 << 30) | (1 << 31);
// Send the formatted messages
PostMessage(gameWindow, WM_KEYDOWN, (WPARAM)key, lParamDown);
Sleep(50); // Important: Give UE's tick rate time to process the Down state
PostMessage(gameWindow, WM_KEYUP, (WPARAM)key, lParamUp);
printf("[Action]: Sent UE-Formatted Background Key: %c\n", key);
}
else
{
printf("[ERROR] Could not find the UnrealWindow!\n");
}
}
void InspectUIWidgets()
{
for (int i = 0; i < SDK::UObject::GObjects->Num(); ++i)
{
SDK::UObject* Obj = SDK::UObject::GObjects->GetByIndex(i);
if (!Obj || Obj->IsDefaultObject()) continue;
if (Obj->IsA(SDK::UUserWidget::StaticClass()))
{
SDK::UUserWidget* Widget = static_cast<SDK::UUserWidget*>(Obj);
if (Widget->IsHovered())
{
printf("\n[UI WIDGET CLICKED]\n");
printf("Instance: %s\n", Widget->GetName().c_str());
printf("Class: %s\n", Widget->GetFullName().c_str());
}
}
}
}