logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
NWNX4 and WINE

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support
View previous topic :: View next topic  
Author Message
OVLD_NZ



Joined: 14 Nov 2006
Posts: 18

PostPosted: Fri Dec 01, 2006 5:17    Post subject: NWNX4 and WINE Reply with quote

Has anyone tested the NWNX4 on WINE? If so what errors are being experienced? (If any) Or has it been successful?
_________________
The World of Judur - The Shadow has Awoken
Back to top
View user's profile Send private message
Nighty



Joined: 22 Dec 2006
Posts: 5

PostPosted: Fri Dec 22, 2006 21:40    Post subject: Reply with quote

I tried NWNX4 with wine and got the following output:

Code:

adm@s15204584:~/Neverwinter Nights 2/nwnx4$ wine NWNX4_Controller.exe
fixme:actctx:FindActCtxSectionStringW 00000000 (null) 2 L"msvcr80.dll" 0x337b6c
err:module:LdrInitializeThunk "MSVCR80.dll" failed to initialize, aborting
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\adm\\Neverwinter Nights 2\\nwnx4\\NWNX4_Controller.exe" failed, status c0000142


The fixme-line is something, I also get when evoking the nwn2server just normally, so thats not to worry about.

The issued dll-file msvcr80.dll I have copied to the nwn2-root-directory as well as the nwnx4-directory.
Back to top
View user's profile Send private message
Analaya



Joined: 26 Dec 2006
Posts: 1

PostPosted: Tue Dec 26, 2006 17:23    Post subject: Reply with quote

Besides the msvc*80.dll, you also need the Microsoft.VC80.CRT.manifest file, which you can find in the nwn2 directory.

However, it doesn't start the nwn2server process. And since its kinda vodoo (slightly near impossible) for a win32 process, running with wine, to hook into another win32 process, also running with wine, you can most likely forget that.

If you don't have the money for a windows server (and hosting prices especially in europe are steep for windows hosts) you can use vmware (alas you have to pay for a windows licence here again), forget about nwnx and use wine or you can do the same I did: Throw the towel. Atari and Obsidian ruined a game I had high hopes for Sad
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Tue Nov 13, 2007 12:41    Post subject: Reply with quote

Hello !
I tried to make nwn2server and nwnx4 work under wine and would like to point you to some places reflecting this effort, which not yet was successful, but maybe will be in future if we correctly analysed the problem:

Links:
My whiney post on nwn2forums:
http://nwn2forums.bioware.com/forums/viewtopic.html?topic=597490&forum=119

An attempt to find a solution under Solaris:
http://mail.opensolaris.org/pipermail/tools-linking/2007-November/000945.html

It appears, that there is a fundamental difference between wine and windows concerning the loading and run time linking of kernel32.dll (windows) and kernel32.dll.so (the wine equivalent).
Windows ALWAYS loads kernel32.dll to the address 0x7bf0000, while under wine the kernel32.dll.so is always loaded to another - more or less random address.
This seems to have the breaking of the codehooking mechanism as a consequence and the pointers going wild with a consequently crash of nwn2server.exe.
It is probably possible to fix that as pointed out in the post on the Solaris mailing list.

Maybe some of you more capable than I am can help out with this - nwn2server on its own runs well under Wine/Solaris, only the combo with nwnx4 seems to break due to the incompatibility pointed out above.
This is not a final bulletproof analysis of the problem, but my impression is, this wine developer I was talking with and who run this debuggin session together with me (username "aturkin" on the #winehq channel at irc.freenode.org) and this guy posting at the mailing list above (username tomww at the #opensolaris channel at irc.freenode.org) - they both seemed to know very well what they were doing and quite competent to me.

I tried working on wine on Solaris so far and managed to get the kernel32.dll.so to be loaded at a constant - not changing address, but its not the base address used by standard windows so far.

So - possibly we are a step ahead, but do not yet have a full solution.

Cheers
Mck.
a.k.a. "Yorlik"
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Tue Nov 13, 2007 18:02    Post subject: Reply with quote

64bit and Wine incompatibilities are the limitations of MadCHook.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Tue Nov 13, 2007 19:06    Post subject: Reply with quote

Thats why we are working on wine and the way its DSOs are loaded.

In the meantime I found this here:
http://blogs.sun.com/nike/entry/overriding_symbols_on_win32

I must admit I didn't understand it , but if it is what I think it would be a method to override symbols. Maybe someone could have a look at it and check if this could be a way for NWNX4 to hook the symbols provided by Obsidian without using MadCodeHook ?

EDIT: The approach of symbol overriding won't work, since no NWNXfunctions are exported which could be overridden by some means. If i analyzed right, the hook place obsidian provided is just a series of assembler statements (mov ah <somebyte> - while <somebyte> represents the ascii value of the name of the NWNXfunctions, such that it it can be found by NWNX), where the 6 function places are in a sort of conditional, probably a "case" or "switch" statement of some sort.

I don't know if patching this part of nwn2server could help in a way that it imports a function from a dll - but this would have the drawback to have a new situation after every server update - not really elegant, and I don't even know if patching the nwn2server would be legal.
grumbles
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Thu Nov 15, 2007 23:54    Post subject: Reply with quote

After a lot of frustrating work I tried some new approaches today:

One was to use CreateRemoteThread() to inject the hook dll into the nwn2server. It semi-worked, but crashed on Solaris and didn't provide IPC functionailty or plugin working. On windows I managed to get the dll injected, but somehow the module and plugin support didn't work - the IPC was broken. I believe it is possible to use this method to get rid of madcodehook. But I don't yet understand why the plugin (time) didn#t work in the module.

Then I tried something completely new:

I didn't use dll injection at all.

I used a program called LordPE which is able to modify windows executables.
I changed the import table in the PE header of nwn2server so, that the nwnx4hook dll is required.
Therefore I not only added the dll, but also I added a dummy exported function inside the nwn4hook dll and marked it as imported in the nwn2server header. Without that dummy function the dll didn#t get loaded.

This slightly modified nwn2server (only the header - not the code) loaded the dll - at least I could see this in the output of LordPE, which also can examine at runtime which dlls are loaded.
I chaged nwnx4 gui in controller.cpp such, that the server process only was created the standard way. i tried creating it with immediate executiuon and suspended with later resume, which worked - but again the functionality was not yet there.

So - this is just an intermediate result and not yet a solution - maybe some of you have a good idea how to get the dll working with this method.

The good news is: When i started this modified nwn2server in a wine/Solaris environment it didn't crash and the hook dll was shown in the loaded shares when i used winedbg.
The bad news is I didn't yet manage to get the functionality back.

Input ?


Cheers
~Y.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Fri Nov 16, 2007 14:17    Post subject: Reply with quote

Just a little update:

I finally managed to see the dll gets loaded and initialized.
The hooks seem to get installed, but I get Errors with the loading of the plugin.
The NWNX4_GUI - debug version tells, the IPC server is connected.

All without madchook.dll !

Digging more ...

Cheers

~Y.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Fri Nov 16, 2007 15:26    Post subject: Reply with quote

I finally succeeded to make it work under windows using the PE header edit method.
So - it is not necessary to use madcodehook to get a working NWNX-nwn2server connection.
Unfortunately in Solaris again I have trouble starting the server and getting functionality - at least things are not crashing and the hook dll seems to get loaded when starting nwn2server on its own.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Fri Nov 16, 2007 15:54    Post subject: Reply with quote

HEUREKA !

It works !

I managed to start my patched nwnx4 version on Solaris/wine, make it start the slightly modified nwn2ser which loaded the nwnx4 hook dll and then thing worked.

AND now I am deadly tired ... I'll post an update later - my last Solaris problem simply was a wrong path set in the ini.
So - I need to recheck some things, maybe more can be achieved.

But I think its safe to say the issue is solved.

HEUREKA !

~Y.

Links:
http://arcanima.org/node/1076
http://nwn2forums.bioware.com/forums/viewtopic.html?forum=119&topic=597490
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Fri Nov 16, 2007 21:10    Post subject: Reply with quote

::opens the champagne::
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Fri Nov 16, 2007 22:14    Post subject: Reply with quote

I just learned about Microsofts Detour SDK, which seems to provide additional DLL loading when starting an application.

http://research.microsoft.com/sn/detours/

It has a function named DetourCreateProcessWithDll which is an extended CreateProcess - I don't know if this will work on wine - I'll check.
Maybe its a workaround to avoid PE editing the nwn2server executable.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Sat Nov 17, 2007 23:45    Post subject: Reply with quote

Just made it working with detour .. I posted in the other thread.
Works on Windows and Wine/Solaris.
I left a link to a quick tutorial over there too.

http://www.nwnx.org/phpBB2/viewtopic.php?t=476&postdays=0&postorder=asc&start=30

Cheers
Y.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group