patch.sh 4.0 KB

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