One of the few good things about Stronghold 3 is that it is very easy to mod. All the game scripting and programming can be found in the .v files in stronghold3/assets and opened with a text editor. You'll need this to be able to open the .v files themselves:
http://www.mediafire.com/?e6nfc36cgdvc3wj
As for the legality, as long as you don't go online with any modded files you should be fine (although you'll probably just get OoS errors if the two gamerules.xml files are different)