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

Update 3DMigotoLoader.exe and .py with d3dx.ini config variable reading #34

Open
kvnxiao opened this issue Dec 31, 2023 · 1 comment
Open

Comments

@kvnxiao
Copy link

kvnxiao commented Dec 31, 2023

I noticed that the launch parameter in d3dx.ini wasn't working to auto-launch the game.

The pyinstaller built exe and the python script should be updated to read from the ini with a simple change to the python script. And instead of hardcoding StarRail.exe we should probably also use the target value from the ini as well.

import psutil
from pyinjector import inject
import re

AUTO_LAUNCH_REGEX = re.compile(r"^launch\s*=\s(.*)$")
TARGET_REGEX = re.compile(r"^target\s*=\s(.*)$")


def _load_config() -> tuple[str, str]:
    auto_launch: str = ""
    target_proc: str = ""
    with open("d3dx.ini", "r") as f:
        for line in f.readlines():
            m = AUTO_LAUNCH_REGEX.match(line)
            if m and not auto_launch:
                auto_launch = m.group(1)
            m = TARGET_REGEX.match(line)
            if m and not target_proc:
                target_proc = m.group(1)
    return auto_launch, target_proc


def main():
    auto_launch, target_proc = _load_config()
    if auto_launch != "":
        print(f"Launching ${auto_launch}...")
        psutil.Popen(auto_launch)
    print("Waiting for program...")
    # Iterate over all running process
    while True:
        for proc in psutil.process_iter():
            try:
                if proc.name() == target_proc:
                    print(f"Found {target_proc}")
                    print(proc.name(), proc.pid)
                    inject(proc.pid, "d3d11.dll")
                    return
            except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                pass


if __name__ == "__main__":
    main()
@kvnxiao
Copy link
Author

kvnxiao commented Dec 31, 2023

cc @SilentNightSound (apologies for ping!)

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

No branches or pull requests

1 participant