SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH5 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=249)
-   -   SH5 DLL Injection (https://www.subsim.com/radioroom/showthread.php?t=180760)

TheDarkWraith 02-26-11 11:10 PM

SH5 DLL Injection
 
I've written a little application in managed C# that allows you to pick a DLL to inject into SH5. You can also remove injected DLLs and remove currently loaded DLLs from the SH5 process. I call this application 'SH5 Injector'. This is a scaled down version of my 'DLL Injector' (DLL Injector can inject/remove DLLs into/from ANY process running on your computer)

This app is a 64bit application and thus will not work on 32bit OSs. It is also targeted at the .NET 3.5 framework or higher.

This application is very handy for injecting custom DLLs into SH5 to monitor, replace, extend, or modify in-game code or variables. It can also be used to create DLL hooks on modules loaded into the game (through code in a custom DLL injected into the SH5 process). There are many uses for this :yep: Due to the way that I do the injecting and removing of the DLLs it's very hard to detect and counter (SH5 has no idea that anything happens at all!). Shouldn't trip any anti-virus software either.

As this does not modify the SH5.exe or any game files it is completely legal :up: What it does is inject the dll selected into the current SH5 process or removes the selected DLL from the SH5 process. This is all done using the Win32 API which is part of Windows for those that are not familiar with it.

The UI for the application is very intuitive and easy to use :yeah:

This is the first step to extending, modifying, and/or creating new code for the game :D

In a future release I plan on adding the ability to inject straight code into the SH5 process. I plan on letting you type assembly instructions right into the UI and then the app will compile those into machine code and inject into the process (in it's own memory space :smug:).

To use:
- fire up SH5
- fire up SH5 Injector

32bit version: http://www.gamefront.com/files/20051...Injector32_exe

64bit version: http://www.gamefront.com/files/20049...Injector64_exe

http://www.subsim.com/radioroom/pict...pictureid=3716

THE_MASK 02-27-11 12:19 AM

Sounds like the next step . I think and hope this game will be around for a long time .

mobucks 02-27-11 01:12 AM

dude awesome!

jean74 02-27-11 02:59 AM

Thank you Sir :salute:

dcb 02-27-11 03:14 AM

This looks like a huge breakthrough for this game, the next gen in modding the game. :rock:

stoianm 02-27-11 04:02 AM

fantastic:woot:

maybe it is the time for somebody to start to think how to add snow in the sh5 now

manny thanks TDW:salute:

BigBANGtheory 02-27-11 04:18 AM

If I understand correctly this means you could potentially change core game features to a large extent! :rock:

Choosing my words carefully here... : How would one go about creating a new dll for SH5.exe injection?

kemeri 02-27-11 06:23 AM

I don't understand a word, but sounds great! :D

Will it be possible with such an injections to do/mod, for example:
- snow
- independent control of engines
- complex your own sub damage/trim system
- further IRAI improvements
- .....?

By the way, TDW, how much time have you actually just played the SH5?
Take a break, you are unlocking doors faster then people enter :DL

TheDarkWraith 02-27-11 09:07 AM

Quote:

Originally Posted by BigBANGtheory (Post 1607695)
If I understand correctly this means you could potentially change core game features to a large extent! :rock:

Choosing my words carefully here... : How would one go about creating a new dll for SH5.exe injection?

Yes one can change core game features to a large extent and one can add new features to the game. It's not as easy as it sounds though. Your new content would be in the dll to inject and you hook into the game to have it execute your new code. You add the hook via code in your dll.

I use Visual Studio 2008 C# or C++ to do my programming and my DLL creating. One could use Visual Basic if they wanted to. A DLL is an exe with one bit changed in the PE header to 'make' it a DLL. Any computer language can be used as long as you can compile the source code into a dll.
I'm going to make a sample dll file and include source code so that you can see what this app can do for SH5 :up:

urfisch 02-27-11 01:45 PM

nice!

but what does this injection method make possible?

TheDarkWraith 02-27-11 01:52 PM

Quote:

Originally Posted by urfisch (Post 1608009)
nice!

but what does this injection method make possible?

Anything that you can code in. You can create hooks, replace code, add code, view code, etc. It's just a matter of writing the .dll and injecting it in.
When a dll is loaded into a process the windows loader automatically calls the DLLMain function of the dll. This means your dll is 'run' as soon as it's injected into the process :yeah:

cherbert 02-27-11 02:12 PM

Quote:

Originally Posted by urfisch (Post 1608009)
nice!

but what does this injection method make possible?

I think an extreme example would be that should you have unlimited time, desire and resources to apply to such an undertaking you could use this DLL method to write a whole new Silent Hunter 6 using the existing core 3D engine. This example is far fetched but it helps explain the power now available to the community with this break through. We could be seeing proper un-official patches to the core game engine -however, it will require some highly skilled expert coders. This really is very exciting for Silent Hunter 5!

Not sure if this solves the importing of new 3D models though?

TheDarkWraith 02-27-11 02:39 PM

one could write a .dll to replace an entire function in the sh5.exe by using dll injection. The hardest part is deciphering the assembly language and figuring out what it's doing in the game.
Using OllyDebug you can attach to the SH5 process and suspend the game and 'look inside'. There you can figure out what you want to change/replace/add and write a .dll to replace the code wanted (make note of the RVA so you can modify the correct code!)
I'll try and make a dll (with source) that hooks into the main sh5.exe code and executes a function in that dll. Basically what this dll would do is:
- modify the ingame code to 'jump' to your function and execute it
- once the function in the dll is complete it 'jumps' back to the ingame code like nothing ever happened.
- As this new function is now part of the game code it will be called everytime the code comes to that spot

THE_MASK 02-27-11 03:23 PM

This is prolly lame , but with this could you click on a button in game and bring up google earth and look at your navmarks on google earth while playing the game .

TheDarkWraith 02-27-11 03:31 PM

Quote:

Originally Posted by sober (Post 1608095)
This is prolly lame , but with this could you click on a button in game and bring up google earth and look at your navmarks on google earth while playing the game .

I wouldn't say it's not possible but it would be hard to do. It could be done though. You could do this easier with a game's .py file :yep:


All times are GMT -5. The time now is 12:54 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.