Lauriethefish / QuestPatcher

Generic il2cpp modding tool for Oculus Quest (1/2/3) apps.
zlib License
281 stars 391 forks source link

Run it a second time after patching beatsaber error (Quest 3) #133

Closed agibson2 closed 10 months ago

agibson2 commented 10 months ago

If you close QuestPatcher and run it again after BeatSaber was already modded (to add more mods to BeatSaber), QuestPatcher stops working and gives the error below when you first launch QuestPatcher.

QuestPatcher.Core.AdbException: chmod: chmod '/sdcard/Android/data/com.beatgames.beatsaber/files/mods/' to 0777: Operation not permitted

If I remove BeatSaber and install 1.28.0 again from scratch, the error does not happen. It seems to be any launch of QuestPatcher after patching BeatSaber.

EDIT: changed from 1.27.0 to 1.28.0 (typo).

Lauriethefish commented 10 months ago

Are you on the quest 3?

agibson2 commented 10 months ago

Yea. I put Quest 3 in the Title but I guess I didn't mention it in the comments. I have Quest 3 Beat Saber patched successfully using another patched version of QuestPatcher (https://github.com/timfenton/QuestPatcher) but I noticed it gave this error if I run Quest Patcher again with Beat Saber already patched. This one does the same thing so I figured I would add this issue to this upstream version in case it wasn't known on Quest 3. I was running QuestPatcher a second time to add more mods is how I discovered this.

Lauriethefish commented 10 months ago

Hmm. From the research I did, this seems to be caused by the permissions of the whole file tree being messed up. It will be pretty tricky for me to find the problem, because I don't have a quest 3, but I can try my best.

agibson2 commented 10 months ago

Maybe it is something that the other version of QuestPatcher is doing (odds seem high if the permissions are being messed up). I will start from scratch and use this version of QuestPatcher and see if the same thing happens. Previously I used the other QuestPatcher and then ran this one to see if it had the same error problem whenrunning it after the other QuestPatcher patched things.

agibson2 commented 10 months ago

I guess it is too early to attempt this version of QuestPatcher with Quest 3. I get the error below on Quest 3 trying to patch 1.28.0 version of Beat Saber. The other version of QuestPatcher does patch it on Quest 3 successfully. The only problem with that version is that you can't relaunch any version of QuestPatcher a second time.

I think the way the other version works is that it downloads a patched version of something that was fixed for quest 3 so any official download makes since that it might not work yet until other official sources update for Quest 3. I am only installing the core mods, beattogether, and the cosmetics mod which work properly with the patched file.

....
Copying libmain.so and libmodloader.so . . .
File C:\Users\User1\AppData\Roaming\QuestPatcher\tools\libmain64.so has hash: System.Byte[] 
Closing APK archive . . .
System.Exception: Unable to find download URLs suitable for this QuestPatcher version (0.1.0)
   at QuestPatcher.Core.ExternalFilesDownloader.PrepareDownloadUrls() in D:\a\QuestPatcher\QuestPatcher\QuestPatcher.Core\ExternalFilesDownloader.cs:line 288
   at QuestPatcher.Core.ExternalFilesDownloader.GetFileLocation(ExternalFileType fileType) in D:\a\QuestPatcher\QuestPatcher\QuestPatcher.Core\ExternalFilesDownloader.cs:line 476
   at QuestPatcher.Core.Patching.PatchingManager.PatchApp() in D:\a\QuestPatcher\QuestPatcher\QuestPatcher.Core\Patching\PatchingManager.cs:line 548
   at QuestPatcher.Core.Patching.PatchingManager.PatchApp() in D:\a\QuestPatcher\QuestPatcher\QuestPatcher.Core\Patching\PatchingManager.cs:line 575
   at QuestPatcher.ViewModels.PatchingViewModel.StartPatching() in D:\a\QuestPatcher\QuestPatcher\QuestPatcher\ViewModels\PatchingViewModel.cs:line 57

If you need me to have a live session with you or just chat and do some manual things to help figure things out, let me know. If you just want to wait until BMBF is fixed (hopefully means most official sources/mods are updated form Quest 3) before doing any work, I understand that too.

agibson2 commented 10 months ago

Yea. That QuestPatcher is using a patched libmodloader64.so instead of the official one which isn't Quest 3 compatible yet.

https://drive.google.com/file/d/1pCPLCe3oSIvy_7uSRKsrm5j154xtOJWh/view?usp=sharing

That was discovered by this reddit post where the person that created that modified QuestPatcher had patched QuestPatcher to use that and also do some permission changes it seems that were required to get it to work. Seems likely that the new QuestPatcher by timfenton has extra code causing the issues and maybe not this version. So once the official libmodloader64.so has Quest 3 compatibility, This QuestPatcher might not have issues or might need to do some less obtrusive permission changes.

https://www.reddit.com/r/beatsaber/comments/176v271/how_to_mod_q3/

Lauriethefish commented 10 months ago

I'm happy to live chat, it could be very helpful to find what the permission issue is. You can contact on discord, my username is Lauriethefish, or on reddit, _TheProff_.

I think the way the other version works is that it downloads a patched version of something that was fixed for quest 3 so any official download makes since that it might not work yet until other official sources update for Quest 3. I am only installing the core mods, beattogether, and the cosmetics mod which work properly with the patched file.

Correct, it uses a patched version of the modloader that works on Q3. That version isn't officially out yet, so my repository doesn't contain a link to it (I don't want to use a sketchy drive link.)

The new questpatcher doesn't change much permission stuff, so it may not be the problem fyi.

agibson2 commented 10 months ago

No since in wasting anyone's time. Ill just wait until the official version comes out for libmod... As you said. It might not be a problem for the official stuff.

ericswpark commented 10 months ago

I encountered the same issue and managed to fix it by deleting the two folders (libs and mods).

Lauriethefish commented 10 months ago

No since in wasting anyone's time. Ill just wait until the official version comes out for libmod... As you said. It might not be a problem for the official stuff.

Don't worry, you're not wasting my time. If you help me fix the problem, then it helps lots of other people too, so it's worthwhile.

Lauriethefish commented 10 months ago

I encountered the same issue and managed to fix it by deleting the two folders (libs and mods).

Interesting. I could change questpatcher to delete them if the error occurs.

ericswpark commented 10 months ago

Interesting. I could change questpatcher to delete them if the error occurs.

I actually tried chmod-ing with just adb and found that the directories did not exist at all. So I created them with mkdir but QP would still crash. So I deleted them and ran QP one more time and it worked after that.

Lauriethefish commented 10 months ago

I actually tried chmod-ing with just adb and found that the directories did not exist at all. So I created them with mkdir but QP would still crash. So I deleted them and ran QP one more time and it worked after that.

This should have the same behaviour. Very strange. QP uses ADB for literally every action it makes on your quest, and does the exact same command that I imagine you entered.

FYI, all adb commands that QP executes are logged, check %appdata%/QuestPatcher/logs if you're not sure what QP is executing.

Lauriethefish commented 10 months ago

https://github.com/Lauriethefish/QuestPatcher/commit/67be6401618ce9f07dc822e438cbcc26629e4f1a introduces the workaround @ericswpark mentioned.