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

Replace package/ra2mdlauncher executable with batch script for transparency. #450

Closed
wants to merge 2 commits into from

Conversation

Revival8697
Copy link

@Revival8697 Revival8697 commented Feb 4, 2025

This replace executable with batch script so it is easier to maintain.
As mention in #447 (comment), the hash check is not needed.

@Revival8697 Revival8697 changed the title Replace package/ra2mdlauncher executable with batch script for transp… Replace package/ra2mdlauncher executable with batch script for transparency. Feb 4, 2025
@Revival8697
Copy link
Author

Revival8697 commented Feb 4, 2025

I don't know how, but package/Resources/GameLobbyBase.ini keeps getting into my commit. 😐

Anyway, this should only be temporary until we figure out how to detect Steam's executable properly.

I will do the same thing for RA2. Someone should test this on non-Steam versions.

@SadPencil
Copy link
Member

so it would not be a matter keeping such a mechism.

@SadPencil
Copy link
Member

SadPencil commented Feb 4, 2025

I'm not a fan of that. I would not prefer a plain text script. The current program works well, and at most we can change the name ra2md.exe to Ra2md.exe or whatever for a case-sensitive behavior, or even better, add codes to detect the Steam Stub.
Besides, the original program use 5 MB to determine the size while you changed it to 5 MiB without providing a reason.

@SadPencil
Copy link
Member

SadPencil commented Feb 4, 2025

Again, I object such a change if it merely achieves transparency, leaving a file without proper icon that might confuse a user.

You can indeed write a program to robustly determine if ra2(md).exe is a Steam stub, launching game(md).exe instead if ra2(md).exe is a Steam stub or is missing. Such a design will be better than the current.

Comment on lines +26 to +27
set "ra2MdPath=%appPath%RA2MD.exe"
set "minSize=5242880" :: 5 MiB in bytes
Copy link
Member

@SadPencil SadPencil Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I can now confirm the legit version from a retail CD has the filename Ra2md.exe where only R is capital. For an Origin or FD copy I don't have access right now.

Please provide a good reason changing 5000000 to 5242880.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check for every possible case then.

I assumed the size wouldn't be smaller, so I took the exact size of Steam's RA2MD.exe. However, I prefer an exact byte number, and 5 MiB is conveniently just smaller than 5,286,208 bytes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original 5000000 was selected because it was the median between a gamemd without HD icon and a gamemd with an HD icon. We should tolerate possible reduction of the file size so 5000000 is a good separator.

Comment on lines 36 to 48
if defined fileSize (
if "%fileSize%" GEQ "%minSize%" (
echo Launching gamemd.exe
start "" "%gameMdPath%"
) else (
if exist "%ra2MdPath%" (
echo Launching RA2MD.exe
start "" "%ra2MdPath%"
) else (
echo RA2MD.exe not found. Launching gamemd.exe instead.
start "" "%gameMdPath%"
)
)
Copy link
Member

@SadPencil SadPencil Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original ra2mdlauncher passes through all parameters into the final exe (e.g., -SPEEDCONTROL etc), providing a seamless replacement. Your script does not pass through parameters.

@Revival8697
Copy link
Author

Revival8697 commented Feb 4, 2025

Again, I object such a change if it merely achieves transparency, leaving a file without proper icon that might confuse a user.

The average user would not typically poke around random files. The file is intended for them to launch through the CnCNet client, so the icon should not matter. This batch file is designed for people like me, who explore and found an EXE file and need to trace its source. Now, they can simply open the file and read it in plain text, which is arguably more user-friendly (but again, not that it is intended for any user to open).

...
Also using the official icon really confused me - I now have 5 files with the same icon, excluding the icon file itself. Perhaps using an icon that says launcher next time, you won't have to worry about copyright stuff too (but I guess EA green lighted it).

bad_ux
I guess the first one is different if you stare at it long enough?

@SadPencil
Copy link
Member

SadPencil commented Feb 4, 2025

Well... I suggest you spend time on investigating how to robustly determine if ra2(md).exe is a Steam stub.
If you can provide a program with the following behavior, it will be great.

  1. Handle the case if Ra2md.exe is missing
  2. Determine by hash first (we can add the SHA-1 you have provided for the initial gamemd.exe delivered in Steam)
  3. For an unknown gamemd.exe, determine by examining whether Ra2md.exe is a Steam stub (replacing the file size check)

@Revival8697
Copy link
Author

how to robustly determine if ra2(md).exe is a Steam stub

I don't think I want to touch HEX values for now.

@SadPencil
Copy link
Member

how to robustly determine if ra2(md).exe is a Steam stub

I don't think I want to touch HEX values for now.

Well... then we have no good reason replacing the current launcher I suppose? I will add the hash you have provided and use "Ra2md.exe" as the filename (if FD and Origin version shares this name as the retail CD). The icon can be reworked too.
For the Steam stub, another launcher exe will be provided to conditionally launch "Ra2.exe" or "game.exe", in case the Steam is not running.

if defined fileSize (
if "%fileSize%" GEQ "%minSize%" (
echo Launching gamemd.exe
start "" "%gameMdPath%" %*
Copy link
Member

@SadPencil SadPencil Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the Windows command line is robust enough to pass through arguments. It is hard to solve the injection attack barely using a cmd script, for example, when the parameter is &pause (type ^& pause when launching your script from a cmd console)

@Revival8697
Copy link
Author

I will refrain from touching Windows's executable, for now.

@Revival8697 Revival8697 closed this Feb 4, 2025
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

Successfully merging this pull request may close these issues.

2 participants