Welcome to Soldier of Fortune Community Forums
18 Sep 2018, 17:01


View unanswered postsView active topics



Reply to topic  [ 20 posts ] 
Compiling the source code that comes with the SDK 
Author Message
United States of America

User avatar

Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
I'm finding myself constantly asking questions here, but I guess now that I've finally found this forum, I've decided to ask about some issues regarding the game as you guys are obviously the most knowledgeable. Anyways, I've decided to download the SDK that comes with the source code, because there are a few things I want to tweak.

The main thing I want to tweak are the weapons enemies have, or at the very least increase the amount of ammo I start with as well as max ammo I can carry in reserve. I mainly want to do this because the Silver Talon, or Desert Eagle, is my favorite weapon in the game, and while certain levels have enemies that use them often, so I can easily collect ammo for them, some levels have decidedly limited ammo. Soldier of Fortune 2 externalizes what weapons enemies use, and how much ammo the player can carry, for that matter, so it was fairly easy to modify the files to make every enemy drop a Silver Talon in that game (even though the base game didn't even include that gun in the campaign normally). However, it seems like Soldier of Fortune has most of this stuff coded into the source code.

So now the problem I have is this: how do I compile the code? I managed to successfully compile player.dll once using a very old Visual C++ 6 (that Raven themselves used when making the game), but I replaced the player.dll that came with the game and it crashes as soon as I load a level. I assume, in that case, that the source code is different to what the game eventually became, which makes sense. In that instance, what code do I need to use? How would I compile it? What IDE do I need to use? Basically, what are the steps needed for me to do what I want to do with the game, which is replace enemy weapons and/or change how much ammo the player can carry at maximum and starting a level. If I can just get the latter done, I don't even need the former as I can just start with full ammo for the Silver Talon, which should be enough for me to at least use it fairly regularly in all levels.

Thanks for anyone who reads through my giant wall of text. This is my first time hardcore trying to fiddle around with the game, and you guys probably know much more than I do.


23 Mar 2018, 04:18
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
I once tried the same thing, compiled it but it crashed as soon as I tried to use it.  I wouldn't recommend trying that avenue, your only bet would be loading your own dll in to memory and using pointers to memory and perhaps also code interception (aka function detours/hooks) to get the job done.  This way the source code (sdk) is a strong approximation/guide to what you will find in memory, of course you will need the help of a debugger/disassembler like IDA eg. . Some of these steps have their own mini challenges, let me list some links to help you.

IDA Free
IDA Support: Freeware Version
A Detour Library To Aid the Interception
http://185.62.190.110/collaborative/too ... tourXS.rar
An Injector, as a method for getting your dll loaded by SoF.exe
https://www.unknowncheats.me/forum/down ... ile&id=578

If you dont want to use an injector you can find other ways to do it, look online.

So there you have it, not the easiest solution, but depends on your skill level and dedication.


23 Mar 2018, 12:39
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
I once tried the same thing, compiled it but it crashed as soon as I tried to use it.  I wouldn't recommend trying that avenue, your only bet would be loading your own dll in to memory and using pointers to memory and perhaps also code interception (aka function detours/hooks) to get the job done.  This way the source code (sdk) is a strong approximation/guide to what you will find in memory, of course you will need the help of a debugger/disassembler like IDA eg. . Some of these steps have their own mini challenges, let me list some links to help you.

IDA Free
IDA Support: Freeware Version
A Detour Library To Aid the Interception
http://185.62.190.110/collaborative/too ... tourXS.rar
An Injector, as a method for getting your dll loaded by SoF.exe
https://www.unknowncheats.me/forum/down ... ile&id=578

If you dont want to use an injector you can find other ways to do it, look online.

So there you have it, not the easiest solution, but depends on your skill level and dedication.


Man, all of this sounds way more complicated than I was anticipating. Are you sure this is the only way?


23 Mar 2018, 16:21
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
I could try to implement it for you, since I have this all laid out for other types of mods already. send me an email via if you are interested. I'll pm you my email.


23 Mar 2018, 16:46
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
I could try to implement it for you, since I have this all laid out for other types of mods already. send me an email via if you are interested. I'll pm you my email.

Ah, thank you.


23 Mar 2018, 16:48
Profile
Netherlands

User avatar

Joined:
Fri May 23rd, 2014
Posts: 478
Reply with quote
d3nd3 wrote:
I could try to implement it for you, since I have this all laid out for other types of mods already.send me an email via if you are interested. I'll pm you my email.

:unsure: Are some/those finished ? are they still likely to be published ?


23 Mar 2018, 19:36
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
By the way, have you considered using 'cheats 1'

Then command :

gimme item_weapon_pistol2

It drops a Desert Eagle in front of you.  You can bind it to a key, or make a script that drops lots of them.

eg. deserteagle.cfg
gimme item_weapon_pistol2
gimme item_weapon_pistol2
gimme item_weapon_pistol2
gimme item_weapon_pistol2
gimme item_weapon_pistol2

in game :
bind c "exec deserteagle.cfg"


24 Mar 2018, 10:43
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
By the way, have you considered using 'cheats 1'

Then command :

gimme item_weapon_pistol2

It drops a Desert Eagle in front of you.  You can bind it to a key, or make a script that drops lots of them.

eg. deserteagle.cfg
gimme item_weapon_pistol2
gimme item_weapon_pistol2
gimme item_weapon_pistol2
gimme item_weapon_pistol2
gimme item_weapon_pistol2

in game :
bind c "exec deserteagle.cfg"


Yeah I know about that, but I much prefer modding the game in a way so I don’t have to do that, you know? I could spawn a Desert Eagle in Soldier of Fortune 2, but I wanted it in the loadout screen and enemy drops.


24 Mar 2018, 17:13
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
Here is a modified player.dll with increased Silver Talon Max Ammo Capacity from 90 to 180. Its also required to have the modified menu so that it defaults to 180 ammo.


Attachments:
File comment: backup player.dll in base dir if you want to undo changes. else just extract to sof1 folder
180AmmoTalon.zip [49.43 KiB]
Downloaded 9 times
28 Mar 2018, 00:16
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
Here is a modified player.dll with increased Silver Talon Max Ammo Capacity from 90 to 180. Its also required to have the modified menu so that it defaults to 180 ammo.

Cool thanks. I’ll be back home soon to test it out, though I’m not exactly sure what the modified menu is.

EDIT: So it seems like the increased ammo works, though I'm still in the middle of a mission so I don't know how the loadout works yet.

I also haven't encountered any crashes yet with the method I used for the effects as related to the other thread, but I haven't played a level with a tank yet. Might go back later.

EDIT 2: So the loadout seems to work, and gave me 180 Desert Eagle rounds too. I also did play a section where I blew up a tank, albeit it was in Iraq so it's different from the tanks in the Siberia levels.

EDIT 3: I have to ask, how did you manage to compile the game so that it doesn't crash? The way I used didn't work. For instance, I would also like to change the starting weapon of the first two levels, where you don't choose your loadout, to start with a Desert Eagle with full ammo. I might also wanna do some stuff like change what weapons enemies drop, if at all possible. Not gonna ask you to do it, as you've done more than enough for me (though if you decide to anyways, I'd thank you a lot), but I might want to fiddle around with it myself.


28 Mar 2018, 02:08
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
Well I didn't compile anything.  Its all reverse engineering using IDA.  I search for ways i can modify the executable in its binary/compiled form.  Some things are hard coded into the binary, like that max ammo for example, its stored in a table/array, you just need to know its location/address/offset.  Thats what ida is able to do, and having the SoF sdk helps that process alot, there is a technique of locating things in binary/address and noting which part it refers to in the SoF SDK.

The limit to this is that the changes you make are very minimal, for large abrupt changes you'd load your own library/dll into the memory and hijack functions.  Eg. The type of changes i make to binarys mostly change default values, text or sometimes changing/flipping the branch statements so that the logic flows differently.


28 Mar 2018, 10:19
Profile
Netherlands

User avatar

Joined:
Fri May 23rd, 2014
Posts: 478
Reply with quote
d3nd3 wrote:
The limit to this is that the changes you make are very minimal, for large abrupt changes you'd load your own library/dll into the memory and hijack functions.  Eg. The type of changes i make to binarys mostly change default values, text or sometimes changing/flipping the branch statements so that the logic flows differently.


Isn't this basically how those dende/djeje bot's work ?
I wasn't around in the period those saw the day of light.


28 Mar 2018, 10:26
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
Yes and go even further back to the seed of it all, GaLLo's MyHealth.dll which read your health value from memory and stored it into a cvar.  And before that haxorcist and wax.  If you want to access a program's memory and have rights to modify it, you gotta be loaded into it. (albeit a few exceptions kernel drivers/ptrace  etc)

And don't forget our boy SoFplus which is a wrapper for WSOCK32.dll , the windows network library which sof loads by default.

EDIT: Dont like talking about aimbot cos not proud of it.


28 Mar 2018, 13:27
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
Well I didn't compile anything.  Its all reverse engineering using IDA.  I search for ways i can modify the executable in its binary/compiled form.  Some things are hard coded into the binary, like that max ammo for example, its stored in a table/array, you just need to know its location/address/offset.  Thats what ida is able to do, and having the SoF sdk helps that process alot, there is a technique of locating things in binary/address and noting which part it refers to in the SoF SDK.

The limit to this is that the changes you make are very minimal, for large abrupt changes you'd load your own library/dll into the memory and hijack functions.  Eg. The type of changes i make to binarys mostly change default values, text or sometimes changing/flipping the branch statements so that the logic flows differently.

Ah, so you essentially just hex editted the original player.dll right? I guess that means changing what guns enemies have or your starting weapons in levels is out of the question, unless that’s externalized in one of the .pak files.

Though wouldn’t changing the ammo size from 90 to 180 be impossible due to the extra character? I always thought trying to go that far in hex would crash.


28 Mar 2018, 15:55
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
Well, not if the variable size was an integer, an integer is 4 bytes long and can hold a number as large as 2,147,483,647 if its signed. Integers use 4 bytes to store data, even if they are having numbers less with lots of 00s after. eg 3 would be represented as 00 00 00 03


28 Mar 2018, 19:44
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
Well, not if the variable size was an integer, an integer is 4 bytes long and can hold a number as large as 2,147,483,647 if its signed. Integers use 4 bytes to store data, even if they are having numbers less with lots of 00s after. eg 3 would be represented as 00 00 00 03

Ah, I see now. But I guess doing more advanced stuff like changing what weapons certain enemies use entirely is out of the question.

Wonder if I can increase damage of weapons as well.


28 Mar 2018, 19:46
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
Yea there is ton of things u can do, just needs time and energy :)


28 Mar 2018, 20:40
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
Yea there is ton of things u can do, just needs time and energy :)

Heh, true. Though some documentation on what each things does what would be nice. I can understand the source code just fine, but a lot of stuff in player.dll is jibberish to me.


28 Mar 2018, 21:30
Profile
Great Britain

User avatar

Joined:
Fri Dec 02nd, 2011
Posts: 121
Reply with quote
you gotta learn to read assembly code then. And once you label something, give something a name there, you can just refer to the source code.  Do you understand what i mean?


29 Mar 2018, 10:03
Profile
United States of America

User avatar

Topic author
Joined:
Thu Mar 22nd, 2018
Posts: 23
Reply with quote
d3nd3 wrote:
you gotta learn to read assembly code then. And once you label something, give something a name there, you can just refer to the source code.  Do you understand what i mean?

Sort of. I know some assembly code but I don’t even see that when I’m looking at player.dll in a hex editor. Hrmph.


29 Mar 2018, 16:43
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ] 
Topic Views: 417


Who is online

Users browsing this forum: Bing and 2 guests


Top
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group
www.sof1.org