:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::

Do you want to advertise at Project Perfect Mod. Find out how to do it HERE.

The time now is Tue Oct 27, 2020 7:14 am
All times are UTC + 0
 Forum index » Modding Central » C&C: Remastered Collection Editing Forums » Tutorials Uplink
Step by step on how to get the dll code into the VS debugger
Moderators: Global Moderators
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
jonwil
Grenadier


Joined: 24 Jul 2005

PostPosted: Tue Jun 09, 2020 7:03 am    Post subject:  Step by step on how to get the dll code into the VS debugger Reply with quote

1.Build your mod dll and load the mod into the remaster and activate it.
2.Start ClientLauncherG.exe with the parameter NO_EVENT_HANDLER
3.Pick your game.
4.Let the game load.
5.Activate windowed mode (you want this otherwise you can get stuck where you are stuck on a breakpoint in VS but can't alt-tab to VS because the full-screen game is frozen)
6.Open VS and (using ctrl to select multiple entries in the attach list) attach both to ClientG.exe and InstanceServerG.exe.
7.Let the code run and it will hit your breakpoints. Note that if you sit on the breakpoint too long, ClientG.exe will timeout waiting for data from InstanceServerG.exe and things will stop working.

Back to top
View user's profile Send private message
secondwtq
Light Infantry


Joined: 26 Jun 2010
Location: China

PostPosted: Wed Jun 10, 2020 12:45 pm    Post subject: Reply with quote

Thanks, this guide is extremely helpful!

Note there is a problem that DLLs compiled with /Od crash the game. I did some debugging and got TD running by removing Init_MMX() in DLL_Startup() of startup.cpp (not sure about RA).

Still it's very strange ...

Edit: Alright someone at Westwood just turned a blind eye to calling convention while writing this assembly routine. And "fortunately" it gets by in both MSVC and ICC with optimization. But maybe with optimizations off the register pressure rises. I guess those "real gamedevs" at Westwood/Petroglyph just never debug with /Od?

Back to top
View user's profile Send private message Send e-mail
jonwil
Grenadier


Joined: 24 Jul 2005

PostPosted: Fri Jul 03, 2020 7:41 am    Post subject: Reply with quote

I have figured out how to run clientg.exe directly (e.g. if you want to start it in a debugger rather than attaching to it or if you want to get the game inside something like nvidia nsight to take a look at the graphics rendering).
You need to run ClientG.exe with these parameters GAME_INDEX=0 NO_EVENT_HANDLER MOD_DEBUG REDALERT
Then run InstanceServerG.exe with these parameters while the splash screen is visible GAME_INDEX=0 NO_EVENT_HANDLER MOD_DEBUG CLIENT_PORT=16000 RUN_AS_APP NO_AUTO_EXIT LAUNCH_FROM_CLIENT=

Do that and things should work properly

Back to top
View user's profile Send private message
CCHyper
Defense Minister


Joined: 07 Apr 2005

PostPosted: Fri Jul 03, 2020 1:14 pm    Post subject: Reply with quote

A better solution would be to run a batch script that does that for you.

NOTE: You can use REDALERT or TIBERIANDAWN to choose the game.

Code:
ClientG.exe GAME_INDEX=0 NO_EVENT_HANDLER MOD_DEBUG REDALERT
InstanceServerG.exe GAME_INDEX=0 NO_EVENT_HANDLER MOD_DEBUG CLIENT_PORT=16000 RUN_AS_APP NO_AUTO_EXIT LAUNCH_FROM_CLIENT=

Back to top
View user's profile Send private message
jonwil
Grenadier


Joined: 24 Jul 2005

PostPosted: Fri Jul 03, 2020 11:20 pm    Post subject: Reply with quote

If you need to have one of the binaries (either clientg or instanceserverg) run from inside a specific tool such as nvidia nsight (which I was using yesterday to track down the shader code used to do team color remapping) then a batch file that launches both wont be that useful.

Back to top
View user's profile Send private message
Oofjay
Civilian


Joined: 15 Jul 2020

PostPosted: Wed Jul 29, 2020 9:26 pm    Post subject: Reply with quote

I just cannot get the debugging to work. I've opened ClientLauncherG.exe with NO_EVENT_HANDLER, but when I attach both processes, I cannot see TiberianDawn.dll in the modules window. When I place a breakpoint in UnitClass::Harvesting, it says "No executable code is associated with this line".

Back to top
View user's profile Send private message
jonwil
Grenadier


Joined: 24 Jul 2005

PostPosted: Wed Aug 12, 2020 3:27 am    Post subject: Reply with quote

The game dll isn't loaded until you actually get in-game. If you are still in the main menu etc then its not loaded yet.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
 Forum index » Modding Central » C&C: Remastered Collection Editing Forums » Tutorials Uplink
Jump to:  
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
Quick Reply
Username:


If you are visually impaired or cannot otherwise answer the challenges below please contact the Administrator for help.


Write only two of the following words separated by a sharp: Brotherhood, unity, peace! 

 
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © phpBB Group

[ Time: 0.2886s ][ Queries: 10 (0.1720s) ][ Debug on ]