Compiling the source code that comes with the SDK

Models + Mapping, Computer & SOF Problems.
Post Reply
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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
https://www.hex-rays.com/products/ida/s ... ware.shtml" onclick="window.open(this.href);return false;
A Detour Library To Aid the Interception
http://185.62.190.110/collaborative/too ... tourXS.rar" onclick="window.open(this.href);return false;
An Injector, as a method for getting your dll loaded by SoF.exe
https://www.unknowncheats.me/forum/down ... ile&id=578" onclick="window.open(this.href);return false;

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.
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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
https://www.hex-rays.com/products/ida/s ... ware.shtml" onclick="window.open(this.href);return false;
A Detour Library To Aid the Interception
http://185.62.190.110/collaborative/too ... tourXS.rar" onclick="window.open(this.href);return false;
An Injector, as a method for getting your dll loaded by SoF.exe
https://www.unknowncheats.me/forum/down ... ile&id=578" onclick="window.open(this.href);return false;

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?
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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.
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 2
Posts: 525
Joined: 23 May 2014, 10:09
Location: Samsung smart fridge

Re: Compiling the source code that comes with the SDK

Post by Sauron »

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 ?
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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"
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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
180AmmoTalon.zip
backup player.dll in base dir if you want to undo changes. else just extract to sof1 folder
(49.43 KiB) Downloaded 105 times
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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.
Reactions: 2
Posts: 525
Joined: 23 May 2014, 10:09
Location: Samsung smart fridge

Re: Compiling the source code that comes with the SDK

Post by Sauron »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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.
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

Yea there is ton of things u can do, just needs time and energy :)
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Reactions: 8
Posts: 168
Joined: 02 Dec 2011, 17:23

Re: Compiling the source code that comes with the SDK

Post by d3nd3 »

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?
Reactions: 0
Posts: 23
Joined: 22 Mar 2018, 03:00

Re: Compiling the source code that comes with the SDK

Post by godzilla »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests