AntonnMal / pso2-rsa-injector

MIT License
3 stars 1 forks source link

Got it to work once, then never again. #1

Closed Kiokuu closed 1 year ago

Kiokuu commented 1 year ago

Hi, Firstly, thank you for updating the key dumper and the gist about NGS packets.

I've successfully compiled the DLLs using the MSVC toolchain commands 64bit, and placed the files in the pso2_bin directory. I have generated the keys also and placed them in the correct directories.

The issue is that I managed to get this to work 1 time out of 50+ attempts, starting the launcher through steam and starting, successfully dumping the SEGAKey.blob and swapping the key, albeit having the game running at 1fps and 100% CPU.

Any other time I attempt to start pso2 through steam with cryptbase.dll + detour.dll in the directory, I get a unhandled exception in pso2.exe and the game will close.

Starting pso2.exe directly (with/without arguments) shows the GameGuard splash screen for a few seconds before silently exiting.

I am quite confused as this ran once before, and am unsure if it was just a rare race condition involving GameGuard.

(Edit) I managed to get a dump file miraculously 0xc0000374 (Heap corruption)

ntdll.dll!RtlReportFatalFailure() Unknown ntdll.dll!RtlReportCriticalFailure() Unknown ntdll.dll!RtlpHeapHandleError() Unknown ntdll.dll!RtlpHpHeapHandleError() Unknown ntdll.dll!RtlpLogHeapFailure() Unknown ntdll.dll!RtlpFreeHeapInternal() Unknown ntdll.dll!RtlFreeHeap() Unknown rsaenh.dll!LocalPopulateBCryptPublicKey() Unknown rsaenh.dll!CPImportKey() Unknown cryptsp.dll!CryptImportKey() Unknown pso2bridge.dll!00007ffd99ddfe68() Unknown pso2bridge.dll!00007ffd99ddb10b() Unknown pso2bridge.dll!00007ffd99dddb77() Unknown pso2bridge.dll!00007ffd99dddc65() Unknown pso2bridge.dll!00007ffd99dc150c() Unknown pso2bridge.dll!00007ffd99dc4c76() Unknown pso2.exe!00007ff782b11d3a() Unknown pso2.exe!00007ff782b12b1a() Unknown kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown

Potentially useful additional info: OS: Windows 11 22H2 build 22621.1702

Thank you in advance for any guidance / potential resolutions to this issue.

AntonnMal commented 1 year ago

Hello, Thank you for your feedback.

The C version was built on many assumptions, so I'm not really surprised it broke.

...I get a unhandled exception in pso2.exe and the game will close.

Did you get a GameGuard popup before the crash? I have a feeling that the problem came from code hijacking. The detour part of the code is not good, but I'm surprised that it worked once.

...having the game running at 1fps and 100% CPU.

Did you have the same performance issues before trying the DLLs?

Starting pso2.exe directly (with/without arguments) shows the GameGuard splash screen for a few seconds before silently exiting.

This is the intended Sega behavior. Upd: To launch it directly, navigate to the game's root folder (PHANTASYSTARONLINE2_NA_STEAM) and run it as:

.\pso2_bin\pso2.exe -reboot -optimize

Upd2: Forgot to mention that you also have to create a steam_appid.txt file in the root directory containing 1056640.

Because the C code is kind of hard to maintain, I've decided to rewrite the code in Rust (and injecting into other functions). Let me know if this improves the situation (tbh, I understand the Rust code a little bit more, so maybe I can help a bit more). Just a heads up: Windows Defender tags the injector as malware, so run at your own risk.

Kiokuu commented 1 year ago

The rust version works perfectly from as far as I can see! Thanks for such a quick response and rewrite! Once again, thank you for maintaining this project.

Closing this issue as original issue solved

Answers to previous questions incase curious:

Did you get a GameGuard popup before the crash? I have a feeling that the problem came from code hijacking. The detour part of the code is not good, but I'm surprised that it worked once.

No, the only GameGuard popup I would get is the downloader/initializing splash screen. However, amazingly, after adding the steam appid to pso2_bin aswell and directly launching it from there, and a system restart overnight, it appears to work every time now, albeit with the 100% cpu issue. I am still confused on why it worked one time. Perhaps I ran the game in a different way without realizing that one attempt.

Did you have the same performance issues before trying the DLLs?

No, Usually able to run the game at maximum settings with high frames and the rust version did not have the same problem

AntonnMal commented 1 year ago

Thank you for your feedback, always appreciated