View previous topic :: View next topic |
Author |
Message |
XShocK
Joined: 24 Sep 2006 Posts: 8
|
Posted: Sun Sep 24, 2006 7:20 Post subject: NWN/NWN2 network layer reverse engineering. |
|
|
Has anyone tried to do the full reverse engineering of the network protocol of NWN/NWN2? I am yet to find anything like that anywhere. I would like to attempt that. If there is such a project, please direct me there. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun Sep 24, 2006 9:50 Post subject: Re: NWN/NWN2 network layer reverse engineering. |
|
|
XShocK wrote: | Has anyone tried to do the full reverse engineering of the network protocol of NWN/NWN2? I am yet to find anything like that anywhere. I would like to attempt that. If there is such a project, please direct me there. | What for? What do you want to know?
IMO, full reverse engineering of the network protocol doesn't make sense. |
|
Back to top |
|
|
XShocK
Joined: 24 Sep 2006 Posts: 8
|
Posted: Sun Sep 24, 2006 20:06 Post subject: |
|
|
To extend abilities of the current(coming for nwn2) game server and possibly eliminating the original server altogether. Such ability would be a dynamic creation of locations such as player's homes. Currently rudimentary features of player's homes are possible. They have to be pretty much identical from inside. In the toolset a builder should create [MAXIMUM NUMBER OF PLAYERS ONLINE] home locations to fit all players at the same time.
So, for example to implement that we have to be able to:
1) Create the location(which has nothing to do with network).
2) Send players to our location(which also includes sending users the location data).
3) Handle players movements in the house.
4) Handle players putting/removing/opening/closing of objects such as closets and boxes.
5) Optionally handling more ppl in the same location. Which is not as hard given we know how to do it for one. It is just a matter of writing the initial code with such a thing in mind.
6) Optionally handle all other events that ppl can do( emotions, spells and etc) since given the initial stage we don't quite need that. It can be ignored for now.
*Also from item 6 we can derive that we could limit people's actions in any way we want by simply blocking it from the original server. For example not allowing to shout/cast spell(s)/articulate in the region of circle around a certain point in the middle of the location.
So to implement houses we could do it with this 6 items. Injecting and filtering is possible now without any winpcap routine(since it is faily slow) by simply changing the original server's networking routine. Not sure what Talus Speech routine is doing currently, it might be doing exactly that. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun Sep 24, 2006 20:31 Post subject: |
|
|
Writing NWN server from scratch? Ok, go on. |
|
Back to top |
|
|
xaltos
Joined: 03 Jun 2006 Posts: 31 Location: Germany
|
Posted: Sun Sep 24, 2006 21:45 Post subject: |
|
|
This sounds very interesting.
A lot more things are possible as well, with something like this
But I see here one serious problem
Bioware / Obsidian / Atari are maybe not so happy if somebody starts to
reverse engineer the network protocol .
Quote: | You may not decompile, modify, reverse engineer, disassemble or otherwise reproduce the Software.
|
The most files are documented on the web, but not the network protocol.
So better speak with them before you invest a lot of time into it |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun Sep 24, 2006 23:05 Post subject: |
|
|
The specification of NWN protocol might be useful to write NWServer/client alternative.
Everything else can be done by hooking. |
|
Back to top |
|
|
XShocK
Joined: 24 Sep 2006 Posts: 8
|
Posted: Mon Sep 25, 2006 1:09 Post subject: |
|
|
About the legality... It has always been the issue with all games of that sort. It has been the issue with Ultima Online and its emulators UOX/Sphere/RunUO. You can look at RunUO now. You can guess on where I am going with it.
About rewriting server from scratch. That is possible, but will require at least several people to spend quite a bit of time on it. Basically my intention is exactly that in the end. But starting to write from scratch most likely will end up nowhere simply because without even semi-final working result for at least 3-4 months people tend to dim their interest in the project.
By starting at the place where the result can be obtained in man-weeks rather than 5-man-months project can go up to the next stage when the first one is completed with a positive result. More bits and pieces can be added on the way. Basically that is a story of NWNX. It basically started as a hook to a call of SetLocalString. And then we had a Profiler, and then we had Talus Speech engine...
About the implementation of that dynamic home/location idea. It does not require much of server code modification. It can actually be done without a single modification, using only hooks and winpcap. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Mon Sep 25, 2006 10:41 Post subject: |
|
|
What programming/disasm/hooking skills do you have?
Btw, Talus Speech is in the past. NWNX-Chat completely replaced it. |
|
Back to top |
|
|
XShocK
Joined: 24 Sep 2006 Posts: 8
|
Posted: Mon Sep 25, 2006 15:12 Post subject: |
|
|
I implemented the ability to do this in C#(and other stuff of course too), basically it is a permanent storage implemented fully in С# and all Object-Oriented stuff is new, functions like cont.Inventory.Items, area.CreateObjectFromString(new Vector3D(1,1,0),buf), NWN.Manager.GetObjectByID(item_ids[i]); are hooked(in my case server was patched when my plugin started, no hooking since that is slower) much the same way SetLocalString was hooked. It was around 1.5 ago. Then I had no time to invest in... Now I am back on track and not that much interested in converting NWNScript to C#, i implemented around 5% of all NWNScript functions. Back then it was 5%. Now I would like to concentrate of NWN2 and more of a nonhacking, but programming.
I also cracked(no-cd issue) the version of NWN, 1.2* something, do not remember which.
Code: |
namespace Libraries
{
public class Bank
{
int opened = 0;
private void Container_OnOpen(NWN.GameObject from)
{
if(opened == 1) return;
opened = 1;
NWN.Logger.getSingleton().WriteLine("The player opened the bank.");
NWN.IContainer cont = from as NWN.IContainer;
// IF there is anything in the crate, delete it.
uint[] item_ids = cont.Inventory.Items;
for(uint i = 0;i<item_ids.Length;i++)
{
ItemObject item = (ItemObject)NWN.ObjectManager.GetObjectByID(item_ids[i]);
item.Destroy(0);
}
FileStream fs = new FileStream("d:\\saved.txt",FileMode.Open);
AreaObject area = (AreaObject)NWN.ObjectManager.GetObjectByID(1);
BinaryReader reader = new BinaryReader(fs);
if(cont != null)
{
while(fs.Position < fs.Length)
{
int size = reader.ReadInt32();
byte[] buf = new byte[size];
fs.Read(buf,0,size);
GameObject obj = area.CreateObjectFromString(new Vector3D(1,1,0),buf);
if(!obj.IsValid) break;
ItemObject item = (ItemObject)obj;
if(item.IsValid)
{
cont.Inventory.Add(item);
}
else
{
System.Windows.Forms.MessageBox.Show("Straaange");
}
}
}
fs.Close();
}
private void Container_OnClose(NWN.GameObject from)
{
if(opened == 0) return;
opened = 0;
NWN.Logger.getSingleton().WriteLine("The player closed the bank.");
//MessageBox.Show("Closed");
FileStream fs = new FileStream("d:\\saved.txt",FileMode.Create);
NWN.IContainer cont = from as NWN.IContainer;
uint[] item_ids = cont.Inventory.Items;
BinaryWriter writer = new BinaryWriter(fs);
for(uint i = 0;i<item_ids.Length;i++)
{
ItemObject item = (ItemObject)NWN.ObjectManager.GetObjectByID(item_ids[i]);
byte[] buf = item.ToSaveStringAsBytes;
if(buf == null)
{
System.Windows.Forms.MessageBox.Show("Straaange");
continue;
}
writer.Write((Int32)buf.Length);
fs.Write(buf,0,buf.Length);
// delete this item, because it is saved.
item.Destroy(0);
}
fs.Flush();
fs.Close();
}
public Bank()
{
NWN.Logger.getSingleton().WriteLine("Bank module started");
NWN.AreaObject area = NWN.ObjectManager.GetObjectByID(1) as NWN.AreaObject;
if(area != null && area.IsValid)
{
PlaceableObject plc = area.CreateObject((uint)NWN.Constants.OBJECT_TYPE_PLACEABLE,"chest003",new Vector3D(10,10,0)) as PlaceableObject;
if(plc != null && plc.IsValid)
{
plc.Events.OnOpen += new NWN.EventHandler.Event(Container_OnOpen);
plc.Events.OnClose += new NWN.EventHandler.Event(Container_OnClose);
}
}
}
static public void Initialize()
{
new Bank();
}
}
}
|
BTW,
*Raurin is The First Russian NWN Shard*
Raurin Foreva |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Mon Sep 25, 2006 15:27 Post subject: |
|
|
I surmised that you could be a russian. Only russian PW devs can think of such crazy solutions like that.
P.S. Axistown rulz anyway. |
|
Back to top |
|
|
|