ra2yrcpp icon indicating copy to clipboard operation
ra2yrcpp copied to clipboard

Where is the patched "gamemd-spawn.exe"

Open 1099255210 opened this issue 2 years ago • 11 comments

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?

1099255210 avatar Nov 23 '23 19:11 1099255210

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 https://github.com/shmocz/ra2yrcpp/blob/ffb674e9a234dcf7b43e9e138713d7c137a46ee8/Makefile#L82 https://github.com/shmocz/ra2yrcpp/blob/ffb674e9a234dcf7b43e9e138713d7c137a46ee8/Makefile#L86

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.

shmocz avatar Nov 23 '23 22:11 shmocz

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

1099255210 avatar Nov 25 '23 03:11 1099255210

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 avatar Nov 25 '23 14:11 shmocz

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.

shmocz avatar Dec 05 '23 03:12 shmocz

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 avatar Dec 05 '23 06:12 1099255210

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

https://github.com/shmocz/ra2yrcpp/blob/0b295c7d36500d695cb6db23ab27882118179a7f/scripts/run-gamemd.py#L365-L372

1099255210 avatar Dec 05 '23 06:12 1099255210

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.

shmocz avatar Dec 05 '23 06:12 shmocz

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)

1099255210 avatar Dec 05 '23 07:12 1099255210

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>

shmocz avatar Dec 05 '23 07:12 shmocz

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!

1099255210 avatar Dec 05 '23 08:12 1099255210

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 https://github.com/shmocz/ra2yrcpp/blob/ffb674e9a234dcf7b43e9e138713d7c137a46ee8/Makefile#L82 https://github.com/shmocz/ra2yrcpp/blob/ffb674e9a234dcf7b43e9e138713d7c137a46ee8/Makefile#L86

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.

csalinasonline avatar May 12 '24 16:05 csalinasonline