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)

Hartmann 02-27-11 07:16 PM

Quote:

Originally Posted by TheDarkWraith (Post 1607837)
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:

Amazing :DL

could be possible then make a surface warships game or more complex submarines or weapons

TheDarkWraith 02-27-11 07:22 PM

Quote:

Originally Posted by Hartmann (Post 1608285)
Amazing :DL

could be possible then make a surface warships game or more complex submarines or weapons

whatever you code your dll to do and how you hook it into the game will define what changes/additions/removals are incurred in the game :yep:

Krauter 02-27-11 07:36 PM

:D Dam.. I could see the CWSS guys making good use of this in the SH4 Mod Workshop

TheDarkWraith 02-27-11 07:38 PM

Quote:

Originally Posted by Krauter (Post 1608312)
:D Dam.. I could see the CWSS guys making good use of this in the SH4 Mod Workshop

have them contact me and I'll make a version of this injector for SH4 :up:

What most people don't know is that a .exe file is mapped in memory by the Windows loader when the process is started. By copying these memory blocks one can assemble their own .exe file. So after injecting your .dll you could have it save the memory regions to a file (with an appropriate PE header) thus creating a new version of the sh5.exe file (a patched version if you will with your changes). Sounds easy to do but it's rather involved (but doable).

Yamato_NF 02-27-11 08:26 PM

"SH4 Injector": Possibility?
 
DarkWraith,
I think Jhapprich can make good use of this for CWSS, (Cold Warriors: Steel Sharks). which is supposed to bring SH4 into the Cold War!
i posted a reply on the CWSS thread found
here:
http://www.subsim.com/radioroom/showthread.php?t=161396
i said that i would recommend this program and to ask for a 32bit version for SH4:rock::up:
ill shoot him a PM aswell.
Yamato_NF

TheDarkWraith 02-27-11 08:32 PM

Quote:

Originally Posted by Yamato_NF (Post 1608366)
DarkWraith,
I think Jhapprich can make good use of this for CWSS, (Cold Warriors: Steel Sharks). which is supposed to bring SH4 into the Cold War!
i posted a reply on the CWSS thread found
here:
http://www.subsim.com/radioroom/showthread.php?t=161396
i said that i would recommend this program and to ask for a 32bit version for SH4:rock::up:
ill shoot him a PM aswell.
Yamato_NF

I'll start work on making a 32bit SH4 version then :up:

TheDarkWraith 02-27-11 09:47 PM

32bit version released for SH5. You'll have to tell me if this works or not (on a 32bit OS) as I run Windows 7 64bit and this whole WoW (Windows on Windows) stuff screws me up big time :shifty:

Zedi 02-28-11 03:00 AM

Quote:

Originally Posted by sober (Post 1608102)
You can already look at your sunk ship icons on google earth if you go on the official silent hunter 5 site . Not while playing the game though .

This is just awesome and I cannot understand why Ubi not implemented this map in the game now that we have to be online to play. I really miss something like this, it would be so cool to see your activity history on map and also see other players/captains location and recent activity.

Is no way to "suck" this data from g2w.ubi.com and make it available in the game?!

h.sie 02-28-11 04:01 AM

@TDW: Very interesting and promising thread.

Until now I directly injected Hex Code into sh3.exe and some .act files in order to do some realism changes and additions. See this thread for details:

http://www.subsim.com/radioroom/showthread.php?t=174225

I still stick on direct HexCode Injection because I am not very familiar to DLL based code injection.

My question to you is: Does DLL code injection also work for .act files, which are loaded into different memory locations every time a game is started because of address space layout randomization (ASLR) in newer 64 Bit systems?

By the way: In SH3, DLL code injection seems to be very easy, just place your .act file into the sh3 install directory and it will be loaded automatically by sh3.exe when it starts, regardless of it's name.

Thanks very much and good luck!
h.sie

TheDarkWraith 02-28-11 09:45 AM

Quote:

Originally Posted by h.sie (Post 1608494)
My question to you is: Does DLL code injection also work for .act files, which are loaded into different memory locations every time a game is started because of address space layout randomization (ASLR) in newer 64 Bit systems?

By the way: In SH3, DLL code injection seems to be very easy, just place your .act file into the sh3 install directory and it will be loaded automatically by sh3.exe when it starts, regardless of it's name.

Thanks very much and good luck!
h.sie

Every Silent Hunter game will load ANY .act file it finds in it's root directory. What I'm not sure is whether those .act files have a DLLMain function in them (or something similar) and if they do whether it gets called or not by the game or the Windows loader. When the Windows loader adds a library (module) to a process it calls DLLMain on the module when it's loaded. DLLMain is used to initialize the dll (can be used to do other things also).

Your question about DLL code injection for .act files I don't understand. Maybe you're asking if DLL code injection places the loaded module at random memory locations everytime it's injected? If so, the answer is yes. The Windows loader determines where the module will be placed in memory. Now some will say well how can you inject new code if the memory address is always changing? The answer is simple. You hook into the main game code and point it to your code. You have DLLMain do the hook into the main game code (suspend the main game thread - add hook - resume main game thread).

TheDarkWraith 02-28-11 10:32 AM

The 32bit version of SH5 injector has a flaw in it. For those who have downloaded it please do not use! The problem with it is the incorrect RVA is given for the LoadLibrary and FreeLibrary functions in kernel32.dll.

Normally one calls the Win32 API function GetProcAddress to get the address of the function they want to call in a dll. I had problems getting that working correctly with 64bit OS so I found another way to do it. Since I know the base address of kernel32.dll I just add an offset to that base to get to the function(s) I want (I know this offset from using dumpbin on kernel32.dll). Now here's the problem: Win7 64bit uses WoW (Windows 32 on Windows 64) to enable 32bit apps to run in the 64bit environment. When in WoW mode, kernel32.dll is different from the 32bit version of kernel32.dll (there are two versions of it on 64bit). This means the offsets are also different for the functions I need :shifty: I'll be revising the 32bit version with the correct offsets here soon.

EDIT:

problem has been corrected. Now if someone can verify that the 32bit version works I would greatly appreciate it :up: I know the 64bit version works correctly as I run a 64bit OS.

Beltza 02-28-11 11:03 AM

All that sounds great!!!!

:up:

marleymen 02-28-11 03:57 PM

Please moderators, this post should be moved to "SH5 Guru Programming" subforum.

:rotfl2::rotfl2::rotfl2:

Madox58 02-28-11 04:14 PM

Excellent Tool for breaking OSI.exe
:03:
As I don't want to be brigged nor banned?
That's all I'll say on OSI
:haha:

reaper7 06-10-11 12:36 PM

Quote:

Originally Posted by TheDarkWraith (Post 1608732)
EDIT:

problem has been corrected. Now if someone can verify that the 32bit version works I would greatly appreciate it :up: I know the 64bit version works correctly as I run a 64bit OS.


Keep getting an "SH5 Process not found!" error :06:
Is there an SH3 version :)

Sh5 is up and running. SH5Injector32.exe is in SH5 Directory.

TheDarkWraith 06-10-11 02:43 PM

Quote:

Originally Posted by reaper7 (Post 1681178)
Keep getting an "SH5 Process not found!" error :06:
Is there an SH3 version :)

Sh5 is up and running. SH5Injector32.exe is in SH5 Directory.

Do you have SH5 running when you try to run the app? If so, what version of the game do you have (steam, DVD, D2D,)?

I haven't made an SH3 version yet but I will.

reaper7 06-10-11 04:10 PM

Quote:

Originally Posted by TheDarkWraith (Post 1681237)
Do you have SH5 running when you try to run the app? If so, what version of the game do you have (steam, DVD, D2D,)?

I haven't made an SH3 version yet but I will.


Yes SH5 is running and using DVD version patched to 1.2 :03: OS is Win7 32bit.

TheDarkWraith 06-10-11 07:41 PM

Quote:

Originally Posted by reaper7 (Post 1681277)
Yes SH5 is running and using DVD version patched to 1.2 :03: OS is Win7 32bit.

Did you try using the 64 bit version or 32 bit version of the app?

reaper7 06-10-11 08:10 PM

Quote:

Originally Posted by TheDarkWraith (Post 1681382)
Did you try using the 64 bit version or 32 bit version of the app?

Using the 32bit version.

Edit just restarted the PC and now it works - strange. But it works :)

Brumete 06-13-11 02:38 AM

This program does not work on 32bit ... should remove the link for download :salute:


All times are GMT -5. The time now is 11:34 AM.

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.