Skip to content

Conversation

@ZivDero
Copy link
Contributor

@ZivDero ZivDero commented Mar 8, 2025

By default, the game's executable attempts to load blowfish.dll using COM and uses it for encryption and decryptio, which causes ceratin issues on modern operating systems. This PR removes the game's dependency on blowfish.dll.

This PR include code by CCHyper/tomsons26 from Vinifera which is derived from C&C Remastered Collection sources and is licensed under GPLv3, and as such, requires relicensing Phobos under GPL.

@github-actions
Copy link

github-actions bot commented Mar 8, 2025

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@TaranDahl TaranDahl added Interaction Something related to interaction with other extension, program etc. ⚙️T2 T2 maintainer review is sufficient labels Mar 9, 2025
Copy link
Contributor

@chaserli chaserli left a comment

Choose a reason for hiding this comment

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

  • It should be discussed whether straws and pipes should be put into yrpp, and if yrpp should change its license
  • iirc BF in BlowStraw and BlowPipe were something like BlowfishEnginePtr * and had a COM interface. So I assume you're redefining these 2 classes, then you might just use normal smart pointers.

@ZivDero
Copy link
Contributor Author

ZivDero commented Mar 9, 2025

  • It should be discussed whether straws and pipes should be put into yrpp, and if yrpp should change its license
  • iirc BF in BlowStraw and BlowPipe were something like BlowfishEnginePtr * and had a COM interface. So I assume you're redefining these 2 classes, then you might just use normal smart pointers.
  1. IMO they should not; YRpp contain bindings, not reimplementations, and this isn't even present in gamemd.exe
  2. What's the point? This is vanilla code, which works fine. I see no significant reasons to alter it in any way. ALso, it might cause issues, because the memry is being deleted by the game's code, but by our come, so we need to use the game's memory allocator.

@chaserli
Copy link
Contributor

chaserli commented Mar 9, 2025

  1. What's the point? This is vanilla code, which works fine. I see no significant reasons to alter it in any way. ALso, it might cause issues, because the memry is being deleted by the game's code, but by our come, so we need to use the game's memory allocator.

If my analysis were correct, BF in blowstraw/blowpipe were something like BlowfishEngine** not BlowfishEngine*, and the size was 0x1099. Allocation/deallocation were handled by blowfish.dll instead of gamemd. Here you've taken over the entire process so you can use local allocator.

@ZivDero
Copy link
Contributor Author

ZivDero commented Mar 9, 2025

  1. What's the point? This is vanilla code, which works fine. I see no significant reasons to alter it in any way. ALso, it might cause issues, because the memry is being deleted by the game's code, but by our come, so we need to use the game's memory allocator.

If my analysis were correct, BF in blowstraw/blowpipe were something like BlowfishEngine** not BlowfishEngine*, and the size was 0x1099. Allocation/deallocation were handled by blowfish.dll instead of gamemd. Here you've taken over the entire process so you can use local allocator.

Actually, that's not the case, which is something I learnt experimentally. Since the code was borrowed from Vinifera, it originally contained new, which I was forced to replace with GameCreate after the game crashed in vanilla unpactched code attempting to free memory.

Let's just leave legacy code as it is, there is 0 need to any anything about it.

@ZivDero
Copy link
Contributor Author

ZivDero commented Mar 27, 2025

I've gone ahead and
a) Removed the replacements for BlowStraw and BlowPipe, and instead patched the places where BlowfishEngine is allocated.
b) Replaced blowfish.h and blowfish.cpp with those from the Red Alert sources, with minimal adjustments.

Note for @chaserli : It is absolutely valid to replace the COM proxy with the actual class, the only thing that needs to be taken into account is the memory allocation. Having done what I did, it works just fine.

@ZivDero ZivDero requested review from Metadorius and chaserli March 27, 2025 15:37
Copy link
Member

@Metadorius Metadorius left a comment

Choose a reason for hiding this comment

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

Where's the actual license change? :P

@ZivDero
Copy link
Contributor Author

ZivDero commented Apr 10, 2025

Where's the actual license change? :P

#1567

@ZivDero ZivDero merged commit 798d447 into Phobos-developers:develop Apr 12, 2025
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Interaction Something related to interaction with other extension, program etc. ⚙️T2 T2 maintainer review is sufficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants