View previous topic :: View next topic |
Author |
Message |
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Sat May 16, 2009 0:13 Post subject: Thoughts on 64-bit |
|
|
I've been "out of the loop" due to having upgraded computer to XP64 which has basically ended my NWNX projects career =-)
However, I discovered this little gem on madshi.net
madshi wrote: |
madCodeHook does support hooking APIs inside of a 32bit process just fine, regardless of which OS we are talking about, or which bitdepth the OS has. The limiting factor is DLL injection: The current official madCodeHook version can inject DLLs into all running 32bit processes, but automatic injection into newly created 32bit processes on a 64bit OS does not work.
|
In nwserver.cpp, the hook is established as:
Code: |
CreateProcessEx("nwserver.exe", cl, NULL, NULL,FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, si, pi, "nwnx-module.dll");
|
Based on what Madshi tells us, this will not work, and is indeed true -- it does not -- on my XP64 box. However, perhaps with some modification, maybe I can return to the NWN community once again.
I suppose the matter at hand is figuring out how to start the server first, and attaching second, and if that moves things around in memory how to compensate the existing hook set and scan codes.
Hmmmmm, much to dwell on. These are my thoughts on 64-bit. |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sat May 16, 2009 1:34 Post subject: |
|
|
Personally, I just keep a 32-bit VM around (two, actually -- one WinXP, one Linux) and use that for my NWNX stuff. It has the added benefit of being able to use Wireshark and other such tools with far less background noise. _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Sun May 17, 2009 1:02 Post subject: |
|
|
Great idea. I still have the original media from my XP32. I'll have to give it a try.
You using "VMWare" or some other emulation solution tool? |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun May 17, 2009 1:21 Post subject: |
|
|
VMWare (Server and Player are free) or VirtualBox (free, open-source). |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sun May 17, 2009 20:33 Post subject: |
|
|
VMWare, aye, though I've been considering switching to VirtualBox for the whole free software thing. _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Mon May 18, 2009 4:02 Post subject: |
|
|
SUCCESS!!!!!!!!
I think the emulator ideas are awesome and probably a lot more profound than my long-way approach.
But... I read your responses a little too late and had set work on the problem. Fortunately, my labors have prevailed.
It turns out, even with the MySQL 64-bit ODBC/Connector, the 32-bit version of NWNX2 and nwserver work just fine.
In nwserver.cpp in the NWNX2 folder,
Change:
Code: |
void StartServerProcess(LPTSTR cl, STARTUPINFO* si, PROCESS_INFORMATION* pi)
{
CreateProcessEx("nwserver.exe", cl, NULL, NULL,FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, si, pi, "nwnx-module.dll");
}
|
To:
Code: |
void StartServerProcess(LPTSTR cl, STARTUPINFO* si, PROCESS_INFORMATION* pi)
{
CreateProcess("nwserver.exe", cl, sec, sec, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, si, pi);
InjectLibrary((DWORD) pi->hProcess, "nwnx-module.dll");
}
|
Recompile, and your done. You do not need to update to the latest madHook libs -- the old one and the old DLL work just fine.
All my plugins work, ODBC works, even leto works.... I really didn't have to change anything else.
So there you have it, 64-bit compat NWNX2. And to be honest, I thought it would be a lot more complex. I'm still wondering if its too good to be true.
So in my case, I'll be passing on the emulators, but thanks for the tips guys. I should have tried those first than do all this. |
|
Back to top |
|
|
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Mon May 18, 2009 6:22 Post subject: |
|
|
Fyi, it does seem a little racey. Sometimes it doesn't inject, but I just check if the return val on InjectLibrary is FALSE and try again.. seems to work that way. Of course, since I don't run a large PW, can't make any claims to how stable it is over time, but once the dll injection takes I think (knock on wood) it should be alright. |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Tue May 19, 2009 5:00 Post subject: |
|
|
Awesome! Haven't tested it myself, but I can see that working. Good to know! _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Tue May 19, 2009 13:46 Post subject: Does this work? |
|
|
Hey does this actually work?
If so, can someone provide a binary/executable download?
My situation is that I have a Winxp64 bit desktop, and a x86 Dedicated Server situated across the Irish Sea. Lol
So, any time I want to test a new NWNx functionality/script, I've always had to upload to my dedicated server, and then connect.
But if this can indeed get nwnx working on xp64 bit, it would solve alot of my headaches. |
|
Back to top |
|
|
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Tue May 19, 2009 23:03 Post subject: |
|
|
Yes and no. Its pretty squirrely. What I mean by squirelly is sometimes the Inject will fail. When it succeeds, I haven't noticed any instability. Even more confusing, is if you shutdown the server and let the process-watchdog restart it, subsequent restarts (originating from the process-watch dog) won't inject.
You got to exit both the watchdog and the server and start the NWNX2.exe all over again to get a proper "try" at injecting with the code as I have it above. I'd say it almost alternates, like "every other time" it injects successfully, or around 50%.
I have mediated on the idea of calling a deliberately failing UnInjectLibrary call first just to see if there is any residue I don't know about that needs cleaning up from the last one. It might help, even if there is no library to UnInject.
I have developed code to determine if an inject worked (mainly by checking for the presence of nwnx.log after the log rotate).
I have a 32-bit box next to me so I've sort of moved over to that now, but it seems I'm not the only one interested; perhaps I should pursue this development more.
I could send you a binary, but like I said, it wouldn't be worth a damn. Although as a developer it wouldn't be bad since you could just restart it. The catch-22 is if you want to run a "real" NWN server.
I'll play around with it a little more, see if I can come up with a way to get it to inject 100% of the time. I'll also ask around on madshi.net to see if those guys can reveal anything helpful. |
|
Back to top |
|
|
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Wed May 20, 2009 4:42 Post subject: |
|
|
This one is for you Baaleos -
http://metafocus.net/~cs60/NWNX2.rar
source included per gnu public license.
This is in no way a "release" - its more like something I scrapped together between compiles. It has the Uninject idea being applied at the moment, and god only knows how useful/useless that is So far, I've got a few runs successful in a "row" so I'm optimistic, but, yeah, we'll see. Anyway, as far as I am aware, that is closest as your gonna get running NWNX natively (that is, without emulation) on XP64 until further discovery.
"Key Code"-
Code: |
// Fire up the server using normal windows API.
CreateProcess("nwserver.exe", cl, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, si, pi);
// Uninject call fails - nothing has been injected yet!; this is by design and is a workaround to scrub the XP64 kernel.
UninjectLibrary((DWORD) pi->hProcess, "nwnx-module.dll");
//Proceed with normal injection
InjectLibrary((DWORD) pi->hProcess, "nwnx-module.dll");
|
|
|
Back to top |
|
|
Disco
Joined: 06 Dec 2006 Posts: 152
|
Posted: Fri May 22, 2009 17:45 Post subject: |
|
|
We run NWNX2 on a 64-bit XP server. Magnumman posted about this before.
MagnumMan wrote: | Amia (www.amiaworld.net) is running on x86-64. We're using a pre-release madCHook which allows us to run on x86-64, along with NWNX2 32-bit, nwserver 32-bit, and mysql 64-bit. madshi said that this support would come in the next official release in an email I have stored from May 2006. In any case I know it is possible since we're doing it, perhaps a donation to madshi would be in order - I certainly made one. |
MagnumMan wrote: | Why don't you just ask madshi for the 64-bit compabitle madCHook.DLL? Amia is running on Win64 with it just fine... |
I am not sure how he got the pre-release version, but I can tell you it has been running fine for us for years now. |
|
Back to top |
|
|
addicted2rpg
Joined: 01 Aug 2008 Posts: 106
|
Posted: Mon Jun 01, 2009 9:46 Post subject: |
|
|
I remember reading about madshi's prelease but I hadn't worked up the gall to ask him for it since he mentions its for "special customers" and I am by no means a customer. I have a feeling that donating probably helps qualify you as a "special customer."
It would be neat to get this madCHook into the NWNX distro, but that would be somewhat contingent on him giving it to us....... and I really don't want to provoke him smuggling it / discovering what extent we are actually protected by the GPL It'd be poor ettiquette and distasteful anyway.
Well, for everyone else, it seems my workaround above works fine as far as I can tell (and there is still the emulator workaround). Still, its good to know the pre-release is stable and well-tested by Amia. |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Mon Jun 01, 2009 9:52 Post subject: |
|
|
addicted2rpg wrote: | I remember reading about madshi's prelease but I hadn't worked up the gall to ask him for it since he mentions its for "special customers" and I am by no means a customer. I have a feeling that donating probably helps qualify you as a "special customer."
It would be neat to get this madCHook into the NWNX distro, but that would be somewhat contingent on him giving it to us....... and I really don't want to provoke him smuggling it / discovering what extent we are actually protected by the GPL It'd be poor ettiquette and distasteful anyway.
Well, for everyone else, it seems my workaround above works fine as far as I can tell (and there is still the emulator workaround). Still, its good to know the pre-release is stable and well-tested by Amia. |
There may be a 'free' alternative - a little more advanced than just 'Detours'
EasyHook - The reinvention of Windows API Hooking
It's due for an update in the next month or two...
Cheers
Gryphyn |
|
Back to top |
|
|
maddogfargo
Joined: 03 Nov 2009 Posts: 49
|
Posted: Tue Nov 03, 2009 23:36 Post subject: |
|
|
Gryphyn wrote: | addicted2rpg wrote: | I remember reading about madshi's prelease but I hadn't worked up the gall to ask him for it since he mentions its for "special customers" and I am by no means a customer. I have a feeling that donating probably helps qualify you as a "special customer."
It would be neat to get this madCHook into the NWNX distro, but that would be somewhat contingent on him giving it to us....... and I really don't want to provoke him smuggling it / discovering what extent we are actually protected by the GPL It'd be poor ettiquette and distasteful anyway.
Well, for everyone else, it seems my workaround above works fine as far as I can tell (and there is still the emulator workaround). Still, its good to know the pre-release is stable and well-tested by Amia. |
There may be a 'free' alternative - a little more advanced than just 'Detours'
EasyHook - The reinvention of Windows API Hooking
It's due for an update in the next month or two...
Cheers
Gryphyn |
Anyone know if this or the pre-release madchook mentioned earlier resolve issues with NWNX2 32bit plugin DLLs not working on XP64? _________________ * illegible scribble * |
|
Back to 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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|