Skip to content

Commit 44462ca

Browse files
committed
feat: update 1.21.120
1 parent 7170043 commit 44462ca

File tree

2 files changed

+38
-41
lines changed

2 files changed

+38
-41
lines changed

src/ForceCloseOreUI.cpp

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
#include <cstdio>
1111

1212
namespace fs = std::filesystem;
13+
#if _WIN32
14+
15+
#include <shlobj.h>
16+
#include <string>
17+
#include <vector>
18+
#include <windows.h>
19+
20+
#endif
21+
1322
#if __arm__
1423
#include <unistd.h>
1524
extern "C" int __wrap_getpagesize() { return sysconf(_SC_PAGESIZE); }
@@ -86,7 +95,9 @@ SKY_AUTO_STATIC_HOOK(
8695
Hook1, memory::HookPriority::Normal,
8796
std::initializer_list<const char *>(
8897
{"? ? ? D1 ? ? ? A9 ? ? ? 91 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? "
89-
"A9 ? ? ? D5 ? ? ? F9 ? ? ? F8 ? ? ? 39 ? ? ? 34 ? ? ? 12"}),
98+
"A9 ? ? ? D5 ? ? ? F9 ? ? ? F8 ? ? ? 39 ? ? ? 34 ? ? ? 12",
99+
"? ? ? D1 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? "
100+
"91 ? ? ? D5 ? ? ? F9 ? ? ? F8 ? ? ? 39 ? ? ? 34 ? ? ? 12"}),
90101
int, void *_this, JavaVM *vm) {
91102

92103
vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_4);
@@ -116,34 +127,24 @@ class OreUi {
116127
#elif __aarch64__
117128
#define OREUI_PATTERN \
118129
std::initializer_list<const char *>({ \
119-
"? ? ? D1 ? ? ? A9 ? ? ? 91 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 E8 03 03 AA" \
120-
})
121-
#define OREUI_registerToggle \
122-
std::initializer_list<const char *>({ \
123-
"? ? ? D1 ? ? ? A9 ? ? ? 91 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? D5 F7 03 00 AA ? ? ? F9 F4 03 03 AA F3 03 00 AA" \
124-
}) \
125-
126-
#define OREUI_getBool \
127-
std::initializer_list<const char *>({ \
128-
"? ? ? F9 ? ? ? F9 ? ? ? B4 E0 03 08 AA ? ? ? F9 ? ? ? F9 ? ? ? B5 ? ? ? 39" \
129-
}) \
130+
"? ? ? D1 ? ? ? A9 ? ? ? 91 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 E8 03 03 AA",\
131+
"? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 ? ? ? A9 FD 03 00 91 ? ? ? D1 ? ? ? D5 FA 03 00 AA F6 03 07 AA" \
132+
}) \
130133

131134
#elif _WIN32
132-
#define OREUI_PATTERN \
133-
std::initializer_list<const char *>({ \
134-
"40 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 78 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 49 8B E9 4C 89 44 24" \
135-
}) \
136135

137-
#define OREUI_registerToggle \
138-
std::initializer_list<const char *>({ \
139-
"89 54 24 ? 53 55 56 57 41 54 41 56 41 57 48 83 EC 60 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 49 8B F1" \
140-
}) \
136+
#include <shlobj.h>
137+
#include <string>
138+
#include <vector>
139+
#include <windows.h>
140+
141141

142-
#define OREUI_getBool \
142+
#define OREUI_PATTERN \
143143
std::initializer_list<const char *>({ \
144-
"48 8B 41 ? 48 8B 90 ? ? ? ? 48 85 D2 74 ? 48 8B 4A" \
144+
"40 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 78 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 49 8B E9 4C 89 44 24", \
145+
"40 55 53 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC 98 01 00 00 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4D 8B F1 4C 89 44 24" \
145146
}) \
146-
147+
\
147148

148149
#endif
149150

@@ -153,24 +154,20 @@ namespace {
153154

154155
#if defined(_WIN32)
155156

156-
std::string getLocalAppDataPath() {
157-
char path[260];
158-
size_t len;
159-
getenv_s(&len, path, sizeof(path), "LOCALAPPDATA");
160-
if (len > 0) {
161-
return std::string(path);
162-
}
163-
char userProfile[260];
164-
getenv_s(&len, userProfile, sizeof(userProfile), "USERPROFILE");
165-
if (len > 0) {
166-
return std::string(userProfile) + "\\AppData\\Local";
157+
std::string getMinecraftModsPath() {
158+
char appDataPath[MAX_PATH];
159+
if (FAILED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, appDataPath))) {
160+
printf("Failed to get APPDATA path.\n");
161+
return "";
167162
}
168-
return ".";
163+
164+
std::string path = std::string(appDataPath) + "\\Minecraft Bedrock\\mods";
165+
return path;
169166
}
170167

171168
std::string getUWPModsDir() {
172-
std::string appDataPath = getLocalAppDataPath();
173-
std::string uwpMods = appDataPath + "\\mods\\ForceCloseOreUI\\";
169+
std::string appDataPath = getMinecraftModsPath();
170+
std::string uwpMods = appDataPath + "\\ForceCloseOreUI\\";
174171
return uwpMods;
175172
}
176173
#endif
@@ -221,8 +218,7 @@ bool updated = false;
221218

222219
SKY_AUTO_STATIC_HOOK(Hook2, memory::HookPriority::Normal, OREUI_PATTERN, void,
223220
void *a1, void *a2, void *a3, void *a4, void *a5, void *a6,
224-
void *a7, void *a8, void *a9, void *a10, OreUi &a11,
225-
void *a12) {
221+
void *a7, void *a8, void *a9, OreUi &a10, void *a11) {
226222
dirPath = getConfigDir();
227223
filePath = dirPath + "config.json";
228224
if (std::filesystem::exists(filePath)) {
@@ -231,7 +227,7 @@ SKY_AUTO_STATIC_HOOK(Hook2, memory::HookPriority::Normal, OREUI_PATTERN, void,
231227
inFile.close();
232228
}
233229

234-
for (auto &data : a11.mConfigs) {
230+
for (auto &data : a10.mConfigs) {
235231
bool value = false;
236232
if (outputJson.contains(data.first) &&
237233
outputJson[data.first].is_boolean()) {
@@ -251,7 +247,7 @@ SKY_AUTO_STATIC_HOOK(Hook2, memory::HookPriority::Normal, OREUI_PATTERN, void,
251247
outFile.close();
252248
}
253249

254-
origin(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
250+
origin(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
255251
}
256252

257253
} // namespace

xmake.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target("ForceCloseOreUI")
2020
add_packages("detours")
2121
remove_files("src/api/memory/android/**.cpp","src/api/memory/android/**.h")
2222
add_cxflags("/utf-8", "/EHa")
23+
add_syslinks("Shell32")
2324
elseif is_plat("android") then
2425
remove_files("src/api/memory/win/**.cpp","src/api/memory/win/**.h")
2526
add_cxflags("-O3")

0 commit comments

Comments
 (0)