-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
105 lines (80 loc) · 2.44 KB
/
main.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "framework.h"
#include "wnd.h"
#include "d3d.h"
#include "dearImGui.h"
#include "options.h"
#include "mem.h"
#include "proc.h"
#include "offsets.h"
#include "addresses.h"
#define hProcess proc->hProcess
// Forward declare message handler from imgui_impl_win32.cpp
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hWnd, message, wParam, lParam))
return true;
switch (message)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
// Entry point for any windows application
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Get target process Id
proc->procId = proc->GetProcId(L"ULTRAKILL.exe");
if (proc->procId)
{
// Get handle to process
hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, proc->procId);
/* Get Modules base address */
addr->moduleBase = proc->GetModuleBase(L"ULTRAKILL.exe", proc->procId);
addr->unityPlayer = proc->GetModuleBase(L"UnityPlayer.dll", proc->procId);
}
// Fullscreen transparent window creation
window->CreateWnd(hInstance);
// Display created window
ShowWindow(window->hWnd, nCmdShow);
// Set up and initialize Direct3D and ImGui
d3d9->initD3D(window->hWnd);
MSG msg;
// Main loop
while (!(GetAsyncKeyState(VK_END)))
{
// Check to see if any messages are waiting in the queue
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (msg.message == WM_QUIT)
break;
// Render frame and ImGui
d3d9->renderFrame();
// -- Menu
if (GetAsyncKeyState(VK_INSERT) & 1)
{
option->bMenu = !option->bMenu;
}
// Calculate target addresses
addr->calcAddresses();
// -- God Mode
if (option->bGodMode)
{
if (addr->hp)
mem->writeMem<int>(hProcess, addr->hp, 420);
}
}
// Clean ImGui
dearImGui->cleanImGui();
// Clean DirectX and COM
d3d9->cleanD3D();
// Return this part of the WM_QUIT message to Windows
return msg.wParam;
}