Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

something for me or someone else to do if they have time #7

Open
3 tasks
UnlegitSenpaii opened this issue Jan 5, 2024 · 9 comments
Open
3 tasks

something for me or someone else to do if they have time #7

UnlegitSenpaii opened this issue Jan 5, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@UnlegitSenpaii
Copy link
Owner

UnlegitSenpaii commented Jan 5, 2024

  • Instead of replacing the conditional jumps with conditional jumps, maybe replace it with just a jump and NOP (0x90) the rest.
  • Improve the Usage guidelines somehow
  • Add a check for already patched patterns to make debugging user problems better :)
@UnlegitSenpaii UnlegitSenpaii added the enhancement New feature or request label Jan 5, 2024
@UnlegitSenpaii
Copy link
Owner Author

UnlegitSenpaii commented Aug 18, 2024

  • move the file loop outside of the replace pattern function so the program only loops once though all memory.

@UnlegitSenpaii
Copy link
Owner Author

UnlegitSenpaii commented Oct 26, 2024

  • implement pattern placeholders, or get the target location with a different method that is more permanent.

@UnlegitSenpaii
Copy link
Owner Author

UnlegitSenpaii commented Oct 27, 2024

  • expand the wiki

@oorzkws
Copy link

oorzkws commented Nov 6, 2024

From your comments:

* todo: instead of doing this, just edit achievements-modded.dat to achievements.dat

I had a user try this earlier today and report that swapping the files didn't work.

I don't know what the actual contents of the files are, but maybe you can replace achievements.dat with a renamed copy of achievements-modded.dat? This probably won't work if the contents of the files are not structurally the same (e.g. if there is an actual "is modded" flag set inside achievements-modded.dat).

"failed to upload achievements" error during the launch

@UnlegitSenpaii
Copy link
Owner Author

From your comments:

* todo: instead of doing this, just edit achievements-modded.dat to achievements.dat

I had a user try this earlier today and report that swapping the files didn't work.

I don't know what the actual contents of the files are, but maybe you can replace achievements.dat with a renamed copy of achievements-modded.dat? This probably won't work if the contents of the files are not structurally the same (e.g. if there is an actual "is modded" flag set inside achievements-modded.dat).

"failed to upload achievements" error during the launch

My comments sometimes make little sense.. What the comment is supposed to mean is that instead of replacing the CMOVNZ instruction to a CMOVZ instruction I just replace the conditional move with a normal move operation.

Doing this (and I think a little more) avoids the isVanilla mess and you can ask the user what achievement file should be active.
See optional patch:

{PATCH_TYPE_CMOVNZCMOVZ, "PlayerData::PlayerData",

Log::LogF("\033[1mDo you want to use the modded achievement save? (y/N)\033[0m\n");

Reading the issue in your repo, I'm a little concerned about the is-modded flag in the achievements-modded file. But I'm pretty sure the other patterns are patching that issue. I need to check that when I'm home so I might be wrong .-.

You can find the pattern for the CMOVNZ thingy by looking at the reference in PlayerData::PlayerData for achievements-modded.dat or achievements.dat and then searching in the assembly view for the CMOVNZ instruction below the reference. It should be pretty close. At least that's how it is in the linux binary, depending on the compiler and the optimization the code in the windows version the decompiled assembly can wildly differ like it already does in other places where entire functions get optimized out.
I can check for the pattern for you in the evening if u want (CET Time).

@oorzkws
Copy link

oorzkws commented Nov 6, 2024

IDA decompile: https://gist.github.com/oorzkws/30c4ba450df2c36fbe5c4950c3dcc8fa#file-playerdata-c-L284

I'm guessing the CMOVNZ referenced is the case at L284:

lea     this, aAchievementsDa ; "achievements.dat"
lea     rdx, aAchievementsMo ; "achievements-modded.dat"
test    al, al
cmovnz  rdx, this       ; _Ptr
mov     [rbx], r14
mov     [rbx+10h], r14
mov     qword ptr [rbx+18h], 0Fh
mov     byte ptr [rbx], 0
mov     rsi, 0FFFFFFFFFFFFFFFFh
mov     r8, rsi
nop     dword ptr [rax+rax+00h]

In the Windows version, the loop at L273 (leaving v12/al as 1) and the loop at L304 (leaving v20/achievementsAreModded as 0) are patched, but this does not seem to allow forcibly loading achievments-modded.dat via file rename.

@UnlegitSenpaii
Copy link
Owner Author

UnlegitSenpaii commented Nov 7, 2024

yeah looks good.
its like you already guessed, the assembly code should reference the following lines:

 v13 = "achievements-modded.dat";
 ->>> if ( v12 ) <<<- 
    v13 = "achievements.dat";

the goal is to patch that to the following:
to (best - currently a todo item)

v13 = "achievements.dat";

or (what I'm currently doing)

 v13 = "achievements-modded.dat";
 if ( !v12 )
    v13 = "achievements.dat";

-> hf playing without mods with that one tho

As to what other places you have to patch, I have no idea. You can use mine as a reference. The linux binary decompiles pretty quickly (compared to the windows binary).

I currently have little time to help since I'm in the process of moving to a different place.
That's why I was in a hurry to implement a pattern that lasts longer than a single game update.

If you need the binary for linux you can either follow the steps here and replacing the items that reference windows with linux or hmu on discord.

I have double checked if my optional patch works and can confirm that it works.
Tested by first unlocking an achievement in an unpached version, then destroying the thing that gave me the achievment and finally patching it and selecting deny when asked for the optional patch. Upon loading into the save I received the steam achievement. I additionally verified this by checking the last change date on my achievments-modded.dat file.

@mrgulka
Copy link

mrgulka commented Nov 9, 2024

@UnlegitSenpaii so what about the Windows version?

@UnlegitSenpaii
Copy link
Owner Author

@UnlegitSenpaii so what about the Windows version?

No time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants