patch.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. DIR=$(dirname "${BASH_SOURCE[0]}")
  3. FILE="UnityPlayer.dll"
  4. CEXE="GenshinImpact_Data/upload_crash.exe"
  5. sum=($(md5sum $FILE))
  6. if [ "${sum}" != "2a7b40cbcf1e0de95900b9f822ad33f9" ]; then
  7. # The patch might corrupt invalid/outdated files if this check is skippd.
  8. echo "Wrong file version or patch is already applied"
  9. echo "md5sum: ${sum}" && exit 1
  10. fi
  11. if ! command -v xdelta3 &>/dev/null; then
  12. echo "xdelta3 application is required"
  13. echo " -> Debian/Ubuntu: apt install xdelta3"
  14. echo " -> Fedora: dnf install xdelta"
  15. exit 1
  16. fi
  17. # ===========================================================
  18. echo "[WARNING] Hereby you are violating the game's Terms of Service!"
  19. echo " Do you accept the risk and possible consequences?"
  20. read -p "Accept? [y/n] " choice
  21. if [[ ! "$choice" == [JjSsYy]* ]]; then
  22. exit 1
  23. fi
  24. echo "--- Setting up blocked servers"
  25. # START OF SUDO DANGER ZONE
  26. etc_hosts="$(cat /etc/hosts)"
  27. # See 110/network.md (up-to-date as of 1.2.0)
  28. servers=$(cat <<EOF
  29. # Genshin logging servers (do not remove!)
  30. 0.0.0.0 log-upload-os.mihoyo.com
  31. 0.0.0.0 overseauspider.yuanshen.com
  32. EOF
  33. )
  34. if [[ ! "$etc_hosts" == *"$servers"* ]]; then
  35. echo "[MANDATORY] Adding following logging servers to /etc/hosts"
  36. echo " If you really really want to skip this (Ctrl+C),"
  37. echo " PLEASE add the entries manually. Otherwise they will receive"
  38. echo " logs about The Wine project, hence UNCOVERING THIS PATCH!"
  39. echo "$servers" | sudo -k tee -a /etc/hosts
  40. if [ $? -ne 0 ]; then
  41. read -p "Please check your /etc/hosts file now. Enter to continue. "
  42. fi
  43. else
  44. echo "-- Logging servers are already blocked. Skip."
  45. fi
  46. servers=$(cat <<EOF
  47. # Optional Unity proxy/cdn servers
  48. 0.0.0.0 prd-lender.cdp.internal.unity3d.com
  49. 0.0.0.0 thind-prd-knob.data.ie.unity3d.com
  50. 0.0.0.0 thind-gke-usc.prd.data.corp.unity3d.com
  51. 0.0.0.0 cdp.cloud.unity3d.com
  52. 0.0.0.0 remote-config-proxy-prd.uca.cloud.unity3d.com
  53. EOF
  54. )
  55. if [[ ! "$etc_hosts" == *"$servers"* ]]; then
  56. echo ""
  57. echo "[Optional] Adding common Unity proxy/cdn servers to /etc/hosts"
  58. echo " Normally this does not cause any issues. If issues arise in other games,"
  59. echo " consider commenting a few lines to check what makes the difference."
  60. read -p "Add 5 servers? [y/n] " choice
  61. if [[ "$choice" == [JjSsYy]* ]]; then
  62. echo "-- Adding proxy/cdn servers"
  63. echo "$servers" | sudo tee -a /etc/hosts
  64. if [ $? -ne 0 ]; then
  65. read -p "--- FAILED to add the servers. What happened?!"
  66. fi
  67. fi
  68. else
  69. echo "-- Unity proxy/cdn servers are already blocked. Skip."
  70. fi
  71. etc_hosts=""
  72. # END OF SUDO DANGER ZONE
  73. echo ""
  74. # No crashes shall be reported!
  75. echo "--- Renaming the crash reporter"
  76. if [[ -e "$CEXE" ]]; then
  77. # Replace existing backups
  78. mv -f "$CEXE" "$CEXE.bak"
  79. fi
  80. # Registry entry to add on startup
  81. cp -f "$DIR/patch_files/mhyprot2_running.reg" .
  82. # Add launcher
  83. echo "--- Adding launcher script"
  84. cp -n "$DIR/patch_files/launcher.bat" .
  85. # Do the patch now, replace existing backups (hash confirmed)
  86. echo "--- Patching UnityPlayer"
  87. mv -f "$FILE" "$FILE.bak"
  88. xdelta3 -d -s "$FILE.bak" "$DIR/patch_files/unityplayer_patch.vcdiff" "$FILE"
  89. # Done!
  90. echo "==> Patch applied! Enjoy the game."
  91. exit 0