mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Check anti-cheat runtime bridges, apply component choices under FEX and honour MAP_FIXED_NOREPLACE above the host limit
This commit is contained in:
1 parent
b1fe206215
commit
19b4844998
2 files changed
+24
-10
No files matched your search
@@ -13,7 +13,7 @@ writes to code in them invalidate translated blocks.
|
||||
Builds on StonkGuy's anti-cheat emulation from https://github.com/StonkGuy/FEX (eac-2611, MIT).
|
||||
---
|
||||
Source/Tools/LinuxEmulation/CMakeLists.txt | 1 +
|
||||
.../LinuxSyscalls/GuestHighMemory.cpp | 439 ++++++++++++++++++
|
||||
.../LinuxSyscalls/GuestHighMemory.cpp | 452 ++++++++++++++++++
|
||||
.../LinuxSyscalls/GuestHighMemory.h | 26 ++
|
||||
.../LinuxSyscalls/SignalDelegator.cpp | 5 +
|
||||
.../LinuxEmulation/LinuxSyscalls/Syscalls.cpp | 30 +-
|
||||
@@ -41,7 +41,7 @@ new file mode 100644
|
||||
index 000000000..a097f97fa
|
||||
--- /dev/null
|
||||
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/GuestHighMemory.cpp
|
||||
@@ -0,0 +1,439 @@
|
||||
@@ -0,0 +1,452 @@
|
||||
+#include "LinuxSyscalls/GuestHighMemory.h"
|
||||
+#include "LinuxSyscalls/Syscalls.h"
|
||||
+#include "LinuxSyscalls/SignalDelegator.h"
|
||||
@@ -155,6 +155,18 @@ index 000000000..a097f97fa
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ bool OverlapsLocked(uint64_t Address, uint64_t Length) {
|
||||
+ const auto Entries = Count.load(std::memory_order_relaxed);
|
||||
+ for (uint32_t i = 0; i < Entries; ++i) {
|
||||
+ const auto Guest = Regions[i].Guest.load(std::memory_order_relaxed);
|
||||
+ const auto Size = Regions[i].Size.load(std::memory_order_relaxed);
|
||||
+ if (Guest < Address + Length && Address < Guest + Size) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ bool UnmapLocked(uint64_t Address, uint64_t Length) {
|
||||
+ const auto End = Address + Length;
|
||||
+ uint32_t i = 0;
|
||||
@@ -252,7 +264,7 @@ index 000000000..a097f97fa
|
||||
+}
|
||||
+
|
||||
+bool ClaimsMapping(uint64_t Address, uint64_t Length, int Flags) {
|
||||
+ if (!(Flags & MAP_FIXED) || (Flags & MAP_FIXED_NOREPLACE) || Length == 0) {
|
||||
+ if (!(Flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) || Length == 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (Address & (FEXCore::Utils::FEX_PAGE_SIZE - 1)) {
|
||||
@@ -271,11 +283,12 @@ index 000000000..a097f97fa
|
||||
+ }
|
||||
+
|
||||
+ BeginWrite();
|
||||
+ bool Ok = UnmapLocked(Address, Size) && AddEntry(Address, Size, reinterpret_cast<uint64_t>(Host), false);
|
||||
+ const bool Taken = (Flags & MAP_FIXED_NOREPLACE) && OverlapsLocked(Address, Size);
|
||||
+ bool Ok = !Taken && UnmapLocked(Address, Size) && AddEntry(Address, Size, reinterpret_cast<uint64_t>(Host), false);
|
||||
+ EndWrite();
|
||||
+ if (!Ok) {
|
||||
+ ::munmap(Host, Size);
|
||||
+ return -ENOMEM;
|
||||
+ return Taken ? -EEXIST : -ENOMEM;
|
||||
+ }
|
||||
+ return Address;
|
||||
+}
|
||||
|
||||
@@ -320,12 +320,12 @@ dd_vacdiag() {
|
||||
|
||||
DD_ANTICHEAT_SETUP = """
|
||||
dd_anticheat_runtime() {
|
||||
local current=$1 name=$2 library
|
||||
if [ -n "$current" ] && [ -n "$(find "$current" -name '*.so' -print -quit 2>/dev/null)" ]; then
|
||||
local current=$1 name=$2 bridge=$3 library
|
||||
if [ -n "$current" ] && [ -n "$(find "$current" -iname "$bridge" -print -quit 2>/dev/null)" ]; then
|
||||
printf '%s' "$current"; return 0
|
||||
fi
|
||||
while IFS= read -r library; do
|
||||
[ -n "$(find "$library/steamapps/common/$name" -name '*.so' -print -quit 2>/dev/null)" ] || continue
|
||||
[ -n "$(find "$library/steamapps/common/$name" -iname "$bridge" -print -quit 2>/dev/null)" ] || continue
|
||||
printf '%s' "$library/steamapps/common/$name"; return 0
|
||||
done < <(printf '%s\\n' "$DD_AC_ROOT" /mnt/droiddeck-sd; sed -n 's/^[[:space:]]*"path"[[:space:]]*"\\(.*\\)"[[:space:]]*$/\\1/p' "$DD_AC_ROOT/steamapps/libraryfolders.vdf" 2>/dev/null)
|
||||
return 1
|
||||
@@ -359,14 +359,15 @@ dd_anticheat() {
|
||||
return 0
|
||||
fi
|
||||
case ${found,,} in
|
||||
*easyanticheat*) runtime=$(dd_anticheat_runtime "${PROTON_EAC_RUNTIME:-}" "Proton EasyAntiCheat Runtime") && export PROTON_EAC_RUNTIME="$runtime" ;;
|
||||
*) runtime=$(dd_anticheat_runtime "${PROTON_BATTLEYE_RUNTIME:-}" "Proton BattlEye Runtime") && export PROTON_BATTLEYE_RUNTIME="$runtime" ;;
|
||||
*easyanticheat*) runtime=$(dd_anticheat_runtime "${PROTON_EAC_RUNTIME:-}" "Proton EasyAntiCheat Runtime" easyanticheat_x64.so) && export PROTON_EAC_RUNTIME="$runtime" ;;
|
||||
*) runtime=$(dd_anticheat_runtime "${PROTON_BATTLEYE_RUNTIME:-}" "Proton BattlEye Runtime" beclient_x64.so) && export PROTON_BATTLEYE_RUNTIME="$runtime" ;;
|
||||
esac
|
||||
if [ -z "$runtime" ]; then
|
||||
echo "droiddeck-proton: anti-cheat files in ${found#$game/}; its Proton runtime is not installed, so this launch stays on ARM64" >&2
|
||||
return 0
|
||||
fi
|
||||
dd_game_cpus
|
||||
declare -F dd_components >/dev/null && dd_components "$tool"
|
||||
echo "droiddeck-proton: anti-cheat files in ${found#$game/}; running ${tool##*/} under FEX" >&2
|
||||
exec ${DD_TASKSET:-} /usr/local/bin/droiddeck-fex proton "$tool/proton" "$verb" "$@"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user