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

Where is the patched "gamemd-spawn.exe" #8

Open
1099255210 opened this issue Nov 23, 2023 · 11 comments
Open

Where is the patched "gamemd-spawn.exe" #8

1099255210 opened this issue Nov 23, 2023 · 11 comments

Comments

@1099255210
Copy link

In the README.md:

Copy libra2yrcpp.dll and patched gamemd-spawn.exe to the CnCNet installation folder (overwriting the original gamemd-spawn.exe) ...

Where can i find the patched gamemd-spawn.exe?

@shmocz
Copy link
Owner

shmocz commented Nov 23, 2023

Hi,

you need to perform the patching yourself. Easiest way to do this is to copy gamemd-spawn.exe to the root folder of the project, and perform the build using Docker: make docker build.
see

$(BUILD_DIR)/.gamemd-spawn.exe: gamemd-spawn.exe
$(BUILD_DIR)/p_text2.txt: $(BUILD_DIR)/.gamemd-spawn.exe

the instructions are a bit confusing. I have a major update coming up, including scripts that greatly simplify the set up process both on Windows and Linux.

@1099255210
Copy link
Author

Thanks! I'll try it before you release the update!

@shmocz
Copy link
Owner

shmocz commented Nov 25, 2023

The latest spawner (gamemd-spawn.exe binary) should be included in the CnCNet YR client package, but you can also get it here: https://github.com/CnCNet/yr-patches/releases/tag/latest
The correct file is in the directory release/cncnet-hardened, although both versions should work fine.

@shmocz
Copy link
Owner

shmocz commented Dec 5, 2023

I've just pushed the update. The patching procedure described in the README has been confirmed to work in Windows dev VM. I couldn't test the Docker environment in Windows, but it should work fine as long as WSL is installed.

Let me know if you find any issues or if there are ambiguities/errors in the documentation.

@1099255210
Copy link
Author

Thanks for the update. I have tried the updated method. The patching procedure has been successful:

[13:48:27] ~\..\ra2yrcpp on develop (base 3.11.5)❯ python ./scripts/run-gamemd.py --build-dir ra2yrcpp --spawner-path gamemd-spawn.exe patch-gamemd --output ra2yrcpp/gamemd-spawn-ra2yrcpp.exe
[INFO] 2023-12-05 14:03:32,710 run-gamemd.run-gamemd.py:70: Logging started at: 2023-12-05T14:03:32.710357, level=INFO
[INFO] 2023-12-05 14:03:32,865 run-gamemd.run-gamemd.py:253: exec: ['ra2yrcpp\\addscn.exe', 'C:\\Users\\pc\\AppData\\Local\\Temp\\tmpsz15xe00\\tmp.exe', '.p_text2', '0x1000', '0x60000020']
[INFO] 2023-12-05 14:03:33,074 run-gamemd.run-gamemd.py:253: exec: ['python', './scripts/patch_gamemd.py', '-s', '.p_text:0x00004d66:0x00b7a000:0x0047e000', '-s', '.text:0x003df38d:0x00401000:0x00001000', '-s', '.p_text2:0x1000:0xc3e000:0x53c000', '-d', '0xc3e000', '-r', 'data\\patches.txt', '-i', 'C:\\Users\\pc\\AppData\\Local\\Temp\\tmpsz15xe00\\tmp.exe', '-o', 'ra2yrcpp\\gamemd-spawn-ra2yrcpp.exe']
[INFO] 2023-12-05 14:03:33,285 run-gamemd.run-gamemd.py:424: patch successful: C:\Users\pc\project\ra2yrcpp\ra2yrcpp\gamemd-spawn-ra2yrcpp.exe

However, after I copied these files (gamemd-spawn.exe, zlib1.dll, ra2yrcpp.dll) into the cncnet folder and overwrote gamemd-spawn.exe, when I launched the LAN game in the cncnet launcher, the game did not start, and it quickly returned to the cncnet lobby.

@1099255210
Copy link
Author

By the way, i modified the python3 to python in the patch command. Command python3 doesn't work for me.

return [
"python3",
"./scripts/patch_gamemd.py",
"-s",
".p_text:0x00004d66:0x00b7a000:0x0047e000",
"-s",
".text:0x003df38d:0x00401000:0x00001000",
]

@shmocz
Copy link
Owner

shmocz commented Dec 5, 2023

However, after I copied these files (gamemd-spawn.exe, zlib1.dll, ra2yrcpp.dll) into the cncnet folder and overwrote gamemd-spawn.exe, when I launched the LAN game in the cncnet launcher, the game did not start, and it quickly returned to the cncnet lobby.

If there's no crash dialog, then a likely reason is that some dependent DLL couldn't be loaded, likely zlib1.dll. I had the impression that Windows looks for DLL's in the folder where the executable resides in, but this might not be the case. It might be failing because the current working directory isn't the CnCNet folder when the spawner is executed. What happens if you open a shell in the CnCNet folder and launch spawner directly with gamemd-spawn.exe -SPAWN?

By the way, i modified the python3 to python in the patch command. Command python3 doesn't work for me.

Thanks for the info! Will fix this in the near future.

@1099255210
Copy link
Author

Nothing happens when I launch the patched spawner, even if I remove the zlib1.dll and ra2yrcpp.dll, no errors.
(The unpatched gamemd-spawn.exe works just fine)

@shmocz
Copy link
Owner

shmocz commented Dec 5, 2023

Just tested it and the reason is missing libwinpthread-1.dll. This should be linked statically, but for some reason it isn't. Due to licensing reasons it cannot be distributed as part of the package.

For a workaround, i'll attach it here. It's the DLL file taken from the Ubuntu based Docker image. Put it into the same folder as the rest of the binaries.
libwinpthread-1.dll.zip

You can also get the DLL by building the docker image with docker compose build builder, then grabbing the DLL:

docker create shmocz/ra2yrcpp
# use the output of above for value of <ID>
docker cp <ID>:/usr/i686-w64-mingw32/lib/libwinpthread-1.dll .
docker rm -v <ID>

@1099255210
Copy link
Author

Just tested it and the reason is missing libwinpthread-1.dll. This should be linked statically, but for some reason it isn't. Due to licensing reasons it cannot be distributed as part of the package.

For a workaround, i'll attach it here. It's the DLL file taken from the Ubuntu based Docker image. Put it into the same folder as the rest of the binaries. libwinpthread-1.dll.zip

You can also get the DLL by building the docker image with docker compose build builder, then grabbing the DLL:

docker create shmocz/ra2yrcpp
# use the output of above for value of <ID>
docker cp <ID>:/usr/i686-w64-mingw32/lib/libwinpthread-1.dll .
docker rm -v <ID>

This works for me, thanks!

@csalinasonline
Copy link

Hi,

you need to perform the patching yourself. Easiest way to do this is to copy gamemd-spawn.exe to the root folder of the project, and perform the build using Docker: make docker build.

see

$(BUILD_DIR)/.gamemd-spawn.exe: gamemd-spawn.exe
$(BUILD_DIR)/p_text2.txt: $(BUILD_DIR)/.gamemd-spawn.exe

the instructions are a bit confusing. I have a major update coming up, including scripts that greatly simplify the set up process both on Windows and Linux.

Nice Work! Would like to see major update soon.

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

3 participants