![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
![]() |
#496 | |
Navy Seal
![]() Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
|
![]() Quote:
long time ago I was a member of the GPx modding community. I remember one of its most respected members was a certain SDI, in the world René Smit. He was the author of GPxPatch: a real time extension of GP3/GP4 fixing many bugs and adding several new features to the game. In my opinion its best feature was not to change any executable: it was changing the code of the game after it was loaded in memory, allowing full configuration by the player. Furthermore, the patch was enabling third parties custom extensions to be loaded and executed within the game. For what I can understand, he was "injecting" his code in the game as you did with dll's with your dll injector. Knowing your love for neat solutions, and seeing the you are moving in the same direction, I wonder if the same can be done with a future release of your patcher. |
|
![]() |
![]() |
![]() |
#497 | |
Black Magic
![]() |
![]() Quote:
Let me ask you this: why inject code into an active process when you can take it's .exe or .dll file, add a section or multiple new sections to it, dump your code into the new section (or sections) in the file, and let the Windows loader do the loading for you? With the adding new sections your code is guaranteed to be where you want it thus making it very easy to get to the other sections. With code injection you have Windows create a new pool of memory for you and you dump your code into that pool. Where that pool of memory ends up being located you have no control over. The only reason I can see for not adding new sections and dumping your code into them in the .exe or .dll file is if the .exe or .dll checks itself when loaded to see if anything is different. But then again one can remove this check from ever happening. If the process is already active (loaded) and you don't have access to the .exe or .dll files then code injection is necessary if one wants to add anything new to it. Looking at GPxPatch I wouldn't like that you have to launch the app wanting to patch from the patch app itself. There's no reason to do this. You can easily get a list of all active processes from Windows and 'attach' to any of them very easily. The patcher has been morphing into something I've been wanting to do for a long time: take an active process and grab all of it's in memory data. Since the PE header is in the process's memory one can theoretically read this PE header and construct an .exe or .dll from the memory read in (a reverse Windows loader). For self-modifying exes this would be one way to 'capture' the image of it in it's modified state thus removing the obfuscation. That's the theory anyway. I'm slowly making my way to see if this theory is correct or not ![]() I can dump memory from any active process, modify it, and inject it back in and the process has no idea anything happened. The patcher is heading in that direction as another way to patch (basically taking functionality from another app I wrote). I've been really ambitious lately and have been trying to modify the sections already defined in an .exe or .dll file. The new version of the patcher allows you to add new sections. These sections are added to the end of the .exe or .dll file. That's cool and all but I want to be able to extend sections already defined ![]() ![]() Another thing I've been working on is being able to 'add' a process to another process. You may ask why would one want/need something like this? Well I have one reason: the Enigma app. The app is perfect replica of an Enigma machine. It works great as a stand-alone process. It cannot be used in any app that does full screen rendering. I've written an app that can 'steal' the main window away from another process and modify it so that it thinks it's the child of the 'stealing' process. Works beautifully. You minimize the 'stealing' process and the other process minimizes also. Now I just have to modify it (Enigma) so that it renders it's window over the full screen app. This is where I need to be able to attach the Enigma process to the full screen process. Last edited by TheDarkWraith; 05-25-12 at 09:22 AM. |
|
![]() |
![]() |
![]() |
#498 | |
Navy Seal
![]() Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
|
![]() Quote:
![]() I was asking if it was possible to inject code in the active process rather than modifying its files for two main reasons: - out of curiosity; ![]() - because I think it would be a cleaner approach than modifing the executable: the lesser common users deal with it, the lesser they risk to screw up things; Anyway, if code injection demonstrated to be a valid approach, my next question was going to be: - would your patcher allow us to change the injected code on the fly, while the game is running, i.e. enabling/disabling patches, changing some fixed parameters, etc? |
|
![]() |
![]() |
![]() |
#499 | |
Black Magic
![]() |
![]() Quote:
![]() The patcher, in it's current state, won't allow you to do what you are wanting (on the fly). I can add that functionality though as it's just merely taking code I've already written and adding it to the patcher app. What I do need to add to the patcher app is a way to dump memory from a process and reload that memory back in. This would allow you to say dump the initialized data from SHSim, modify it, load it back in and see what effect your changes have. Alright I just convinced myself to do this ![]() |
|
![]() |
![]() |
![]() |
#500 | |
Navy Seal
![]() Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
|
![]() Quote:
![]() For sure adding such a functionality would boost significantly our knowledge of SH5 and indeed our modding potential: just think of how many parameters we could experiment with, without having to exit to windows, apply our changes, load again SH5, start a new game... cycle this process for n times, and you will just get sick ![]() |
|
![]() |
![]() |
![]() |
#501 |
Navy Seal
![]() Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
|
![]() |
![]() |
![]() |
![]() |
#502 |
Sonar Guy
![]() Join Date: Sep 2010
Location: Switzerland
Posts: 388
Downloads: 86
Uploads: 0
|
![]()
When using TDW's Generic Patcher remember his note at the bottom of post #1 :
NOTE: DISABLE ALL PATCHES WITH OLD PATCHER BEFORE APPLYING NEW PATCHES WITH NEW PATCHER! THIS APPLIES ONLY TO PATCHES RELATED TO SHSIM.ACT AND SHCOLLISIONS.ACT I read it and forgot about it......and it took me quite a while to get everything fixed again.....
__________________
Von den 40'000 deutschen U-Boot-Männern des Zweiten Weltkrieges kehrten 30'000 nicht zurück... 40’000 German sailors served on U-boats during World War II – 30’000 never returned home... |
![]() |
![]() |
![]() |
#503 |
Nub
![]() Join Date: Mar 2010
Posts: 2
Downloads: 13
Uploads: 0
|
![]()
I have a steam version of the game. I'm sad the current patch will not work with my version, but it sounds like applying the fix at runtime would solve this issue as well.
|
![]() |
![]() |
![]() |
#504 |
Black Magic
![]() |
![]()
v1.0.31.0 released. See post #1
This version adds the ability to attach to a process and inject/remove DLLs. To attach to a process selected File-->Attach. To detach from the process select File-->Detach. To inject a DLL/ACT file click Inject button. To remove a DLL/ACT file from the process select the file you want to remove from the Loaded modules listview. Then click Remove. Everything else should be pretty self-explanatory. If it's unable to inject/remove it's probably because you have older version of kernel32.dll on your computer. Currently I have the offsets for LoadLibraryA and FreeLibrary hard-coded. I have to add code that will read the IAT to get it's address yet. This can be run on 32bit or 64bit OSs. I have it coded to select the appropriate function calls based on whether your OS is 32 bit or 64 bit. Working on the ability to inject/remove files that are nothing but hex code. Since I can't call LoadLibraryA and FreeLibrary on them (they're not DLLs) I have to code in something to allocate process memory and then dump the contents of those files into the new process memory. ![]() |
![]() |
![]() |
![]() |
#505 |
Black Magic
![]() |
![]()
v1.0.33.0 released. See post #1
This version allows you to inject a file (ANY type of file) into a process. You also have the option of executing the file you loaded ![]() If you elect to execute the file you injected, the last command HAS to be a RETN statement (or a RETN x if you need to pop temp variables off the stack). If you forget this the process WILL CRASH! You don't have to add the RETN statement if you are going to branch to somewhere else in the process but in doing so don't forget to pop the return value pushed onto the stack by the stub! The execution will begin at the first byte found in the file. I'll add a way for you to specify beginning execution point in next version. I've included a little file (TestFile(retn).hex) that you can inject into the SH5 process. When it asks if you want to execute it say yes. SH5 will never know anything every happened! The file is just one command, RETN, which means return to caller. Here's how the inject file works: - the app allocates memory in the process in a multiple of pagesize to fit the file being injected - the file contents are copied into this memory - if the user selected execute then: - a stub is made that will branch execution to the injected file. The first thing the stub does is push the EIP to the stack. This way when the injected code issues a RETN statement execution goes back to it's original place ![]() There are two new buttons - Inject file and Remove file. They do just as they sound. To remove a file select the file from the Injections listview and then press Remove file. Working on dumping process memory and reloading it now so user can modify it. Also adding a way to set watches on memory and letting you define the update time interval on them ![]() The LoadLibraryA and FreeLibray offsets are still hardcoded for kernel32.dll. If you get failed to inject or failed to remove it's probably because you have older version of kernel32.dll installed on your computer. I should have these hard codes removed in next version. ![]() |
![]() |
![]() |
![]() |
#506 | |
中国水兵
![]() Join Date: Jul 2011
Posts: 278
Downloads: 941
Uploads: 0
|
![]() Quote:
Thanks |
|
![]() |
![]() |
![]() |
#507 |
Grey Wolf
![]() Join Date: Oct 2005
Location: Bretagne-FRANCE
Posts: 813
Downloads: 155
Uploads: 0
|
![]() ![]() To see this is great ![]() ![]() What this mean in concrete ![]() The possibility of adding what ? - Contollers for. SIM? (Dials, lights ....) - Otherwise to open other programes eg: Enigma, sextant ... - ![]()
__________________
~~~~BigReg~BigRegOne~~~~ ![]() "Better watch where you do not go, because where were going, we will know what it is when we get there, and anyway, it will never be only water." Proverbe Shadok Last edited by BIGREG; 05-26-12 at 02:38 PM. |
![]() |
![]() |
![]() |
#508 | |
Ocean Warrior
![]() |
![]() Quote:
![]() I would say the same thing, but couldn't find the right words.. my poor English.. ![]() I don't understand it myself (my poor English), and I can't explain this in sukhoi.ru.. TDW! Maybe you can make a simple version for children, please!
__________________
. Where does human stupidity end? . ![]() ![]() El sueño de la razón produce monstruos © - and for some people awakening will be cruel |
|
![]() |
![]() |
![]() |
#509 |
Nub
![]() Join Date: May 2009
Posts: 3
Downloads: 5
Uploads: 0
|
![]()
Oh my! I can't seem to find the older patches, but the CO2 fix in the latest asks for it. What do I do?
|
![]() |
![]() |
![]() |
#510 | ||
Black Magic
![]() |
![]() Quote:
Quote:
DLL injection let's you write code in some editor (Visual Studio for instance), compile that code into a DLL, and then inject that into a process to either change it's functionality, override a functionality, and/or add new functionality. Now simply injecting a DLL isn't going to do much. Yes, the DLL is now part of the process but it's never being 'called'. You need to add hooks into the existing code so that your new code is called. If you're really computer saavy you can replace an existing DLL with your own. That lets you do things the app never intended to do (DLL injection/code injection does also but this way is easier for some) Injecting a file is just as it sounds - taking the contents of a file and placing it inside an active process. What does this do for you? I can think of many things! You all are familiar with my patches - you load up the patch file and then you enable the patches you want. Think of those patches as files being injected into the SH5 process (I actually write new data to existing files but it should help you understand the concept). Now for those of you, like me, who love assembly (long live DOS!) injecting a file is the way to go. You can write your 'code' in an assembler, take the hex file generated and inject it into the process. Once I code in the ability to dump and replace process memory then you will have an easy way to add your hooks to call your new code. I'm working on the ability to add watches currently. If your familiar with Visual Studio then you know what watches are already. If not I'll try to make it a little clear: say you have an application that displays a value on a screen and you'd really like to change that value and/or monitor it. We have no idea where this value resides so we have to do a little exploring inside the active process. We pick an area of memory and set a watch on it - the watch will monitor that area of memory for any changes. When it detects changes it can either suspend the process or just update the app with the new value. This allows you to see what that memory is doing in real time. By setting many different watches (and changing what they are monitoring) you will eventually find where the variable is located so you can manipulate it. I made the app generic in nature so that it can be used on anything. It's not fixed to any particular app or process. This app now let's you 'play' in my favorite playground...process memory. You are limited only by your imagination/skill level ![]() ![]() Last edited by TheDarkWraith; 05-26-12 at 04:21 PM. |
||
![]() |
![]() |
![]() |
|
|