This repository has been archived by the owner on May 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
108 lines (81 loc) · 2.99 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
106
107
108
#define _CRT_SECURE_NO_WARNINGS
#include "core.hpp"
namespace anti_cheat {
typedef HANDLE(WINAPI* CREATE_FILE_W)(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
CREATE_FILE_W p_CreateFileW = nullptr;
CREATE_FILE_W t_CreateFileW;
HANDLE WINAPI h_CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
if (memcmp(lpFileName, L"\\\\.\\ACE-BASE", 24) == 0) {
wprintf(L"Thread (%i) attempting to communicate with anti-cheat driver -> %s\n", GetCurrentThreadId(), lpFileName);
SuspendThread(GetCurrentThread()); // 200iq bypass for memory protection
}
return p_CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
void Setup(uint64_t srbase) {
if (MH_Initialize() != MH_OK)
{
puts("Error initializing MinHook library");
return;
}
if (MH_CreateHookApiEx(L"kernelbase", "CreateFileW", &anti_cheat::h_CreateFileW, reinterpret_cast<void**>(&p_CreateFileW), reinterpret_cast<void**>(&t_CreateFileW)) != MH_OK)
{
puts("Error creating hook for CreateFileW function");
return;
}
if (MH_EnableHook(t_CreateFileW) != MH_OK)
{
puts("Error enabling hook for CreateFileW function");
return;
}
Utils::Write<uint32_t>(srbase + 0xFCDC0, 0xCCC3C031);
Utils::Write<uint8_t>(srbase + 0xF9940, 0xC3);
Utils::Write<uint16_t>(srbase + 0x1BCBA0, 0xFEEB);
}
}
void Setup()
{
system("cls");
auto base_address = reinterpret_cast<uint64_t>(GetModuleHandleA("starrailbase.dll"));
if (Utils::GetTextSectionChecksum(base_address) != 0x1434A1A0) {
GlobalSetting::ChinaVersion = true;
puts("[>] China game version detected\n[>] If you don't have the Chinese game version, please create a GitHub issue");
}
anti_cheat::Setup(base_address);
Sleep(15000);
if (!Direct3D.Initialization())
puts("[-] Failed to setup Direct3D!");
else
{
puts("[+] Direct3D setup successfully!");
printf("[>] Direct3D Present: %p\n[>] Direct3D ResizeBuffers: %p\n", Direct3D.Present, Direct3D.ResizeBuffers);
}
if (!Device::Setup())
puts("[-] Failed to setup device hooks!");
else
puts("[+] Device hooks setup successfully!");
return Cheat::Main();
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (!Config::LoadConfig(hModule))
{
// first time user or invalid config
puts("[-] Failed to read config");
// create new config
Config::SaveConfig();
Sleep(200);
// re-attempt load
if (!Config::LoadConfig(hModule))
return false;
}
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Setup, 0, 0, 0);
}
return TRUE;
}