Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit 3b61a1b

Browse files
committed
Fix: disable RWX JIT codepath on Mac Catalyst
It never worked since JVM was modified to test RWX JIT by mmapping a page, but then process can no longer map another RWX region
1 parent c51f1b2 commit 3b61a1b

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ METHOD_DIRCHECK = \
130130
METHOD_CHANGE_PLAT = \
131131
if [ '$(1)' != '11' ] && [ '$(1)' != '12' ]; then \
132132
vtool -arch arm64 -set-build-version $(1) 14.0 16.0 -replace -output $(2) $(2); \
133+
ldid -S -M $(2); \
133134
else \
134135
vtool -arch arm64 -set-build-version $(1) 1.0 1.0 -replace -output $(2) $(2); \
135-
fi
136+
fi \
136137

137138
# Function to package the application
138139
METHOD_PACKAGE = \
@@ -327,6 +328,8 @@ payload: native java jre assets
327328
ldid -S $(OUTPUTDIR)/Payload/PojavLauncher.app; \
328329
if [ '$(TROLLSTORE_JIT_ENT)' == '1' ]; then \
329330
ldid -S$(SOURCEDIR)/entitlements.trollstore.xml $(OUTPUTDIR)/Payload/PojavLauncher.app/PojavLauncher; \
331+
elif [ '$(PLATFORM)' == '6' ]; then \
332+
ldid -S$(SOURCEDIR)/entitlements.codesign.xml $(OUTPUTDIR)/Payload/PojavLauncher.app/PojavLauncher; \
330333
else \
331334
ldid -S$(SOURCEDIR)/entitlements.sideload.xml $(OUTPUTDIR)/Payload/PojavLauncher.app/PojavLauncher; \
332335
fi

Natives/dyld_bypass_validation.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ bool searchAndPatch(char *name, char *base, char *signature, int length, void *t
105105
}
106106

107107
void* hooked_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) {
108+
// this is to avoid a legacy codepath checking if process is allowed to map RWX which never worked properly
109+
if (flags & MAP_JIT) {
110+
errno = EINVAL;
111+
return MAP_FAILED;
112+
}
113+
108114
void *map = __mmap(addr, len, prot, flags, fd, offset);
109115
if (map == MAP_FAILED && fd && (prot & PROT_EXEC)) {
110116
map = __mmap(addr, len, PROT_READ | PROT_WRITE, flags | MAP_PRIVATE | MAP_ANON, 0, 0);

entitlements.codesign.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,13 @@
1313
<string>FBT742498U.*</string>
1414
<string>com.apple.token</string>
1515
</array>
16+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
17+
<true/>
18+
<key>com.apple.security.cs.disable-library-validation</key>
19+
<true/>
20+
<key>com.apple.developer.kernel.extended-virtual-addressing</key>
21+
<true/>
22+
<key>com.apple.developer.kernel.increased-memory-limit</key>
23+
<true/>
1624
</dict>
17-
</plist>
25+
</plist>

0 commit comments

Comments
 (0)