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 
 
Alternatives to MadCHook.dll
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
chaoslink



Joined: 23 Aug 2006
Posts: 37

PostPosted: Mon Jun 25, 2007 19:59    Post subject: Reply with quote

Papillon - You may be interested in what I've done with Detours. I have it hooking for both windows and linux (Detours also provides a "preload" type function such that you can spawn a child process with a specific DLL loaded).

I'm still fixing up some issues, but it is finally coming along.
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Sat Nov 17, 2007 11:25    Post subject: Reply with quote

Did anyone make Detours compile under VC++Express 2005?
The downloadable package relies on a make file with platform switches and such - would be convenient to have it inside the project.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
chaoslink



Joined: 23 Aug 2006
Posts: 37

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

I actually am not using all of detours, just some code ripped out of it, so I can't help you there.

I'm still blocked because I'm unsure what the correct window method signature for SetLocalString is (the code using madcodehook has some assembly around it setting up the stack properly)
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

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

Just finished my first successful server session using detours.
I ripped out some stuff from the withdll.cpp demo to make it work.
I could play the demo module with the time plugin.

Now cross your fingers it will work on wine/Solaris too !

Cheers
McK.
a.k.a. Yorlik


EDIT: It worked !

HEUREKA ! (again)

Wink

EDIT2: I posted a quick and dirty tutorial on how to do it on my website:

http://arcanima.org/node/1077

Its not yet really beutiful, I just wanted to provide a quick orientation how I made it work.

Hopefully things can go upstream soonish.

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



Joined: 16 May 2005
Posts: 40

PostPosted: Mon Nov 19, 2007 1:39    Post subject: Reply with quote

I changed the code a little today.

The solution now no longer needs the detoured.dll file as usually intended by the SDk authors for control reasons, since I elimeinated all references to this nag library and its exported function.

I'm going to change the controller.cpp and move the code I imported there to the sources for the modified microsoft static library - thus the GPLed code of NWNX4 won't get polluted with Microsofts proprietary stuff I am using here - only a function call and a header file include will be left.

If anyone is interested in the code let me know.
I'd be happy to have some people helping test it for stability on wine and the other plugins as well, since I only tried the time plugin so far.
I believe its a safe and stable replacement for madchook.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
GodBeastX



Joined: 09 Aug 2006
Posts: 65

PostPosted: Tue Nov 20, 2007 18:41    Post subject: Reply with quote

I found a light CDetour class someone made for game hacking. Works great, replaces enough opcodes to get a JMP op and then passes you pointer to original to call. Easy as pie, and you just link in 2 .cpp files to your project. I'm using it to hook socket calls on NWN2Server to stop the flooding.
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Tue Nov 20, 2007 21:06    Post subject: Reply with quote

GodBeastX wrote:
I found a light CDetour class someone made for game hacking. Works great, replaces enough opcodes to get a JMP op and then passes you pointer to original to call. Easy as pie, and you just link in 2 .cpp files to your project. I'm using it to hook socket calls on NWN2Server to stop the flooding.


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



Joined: 16 May 2005
Posts: 40

PostPosted: Tue Nov 20, 2007 21:28    Post subject: Reply with quote

I just uploaded the altered test distribution I used to make the version using detours.

If anyone is interested send me a note and register an account on
http://www.arcanima.org
I will activate the account and give you SVN access then.

The (password protected) SVN repository is at
https://svn.arcanima.org/nwnx4exp
Mind the "S" in the https - or you'll get an error when downloading.

I changed some filenames and added a special tag to avoid naming conflicts with the official distribution here.

Once we have a version on NWNX4 which is stable on wine, the SVN repository will get deleted, because I don't want to create a fork.

Its just a temporary development help to review the code and test and maybe incorporate it after modifications.

Cheers
_________________
/McKillroy
a.k.a Yorlik


Last edited by mckillroy on Wed Nov 21, 2007 21:02; edited 1 time in total
Back to top
View user's profile Send private message
GodBeastX



Joined: 09 Aug 2006
Posts: 65

PostPosted: Tue Nov 20, 2007 22:52    Post subject: Reply with quote

http://cheatersutopia.com/forum/showthread.php?p=88807

That thread links to the source code.
Back to top
View user's profile Send private message
Darnah



Joined: 06 Jun 2007
Posts: 15

PostPosted: Wed Nov 21, 2007 11:26    Post subject: Reply with quote

Would the db-connection works with this solution? And when yes, can someone post, how a noob in such things can implement this, please?
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Wed Nov 21, 2007 13:17    Post subject: Reply with quote

In the moment I'm working on testing the solution.

Theoretically all plugins should work, since the major problem of the crashes under wine came from the way of the Dll injection, not from the modules.

Once the Dll is injected into the server and has done its hooking work there is no difference.
It scans for plugins and loads them (tested with the time plugin) and starts the IPC Server used to communicate with the NWNX4_EXP_GUI.exe - same stuff like in the official NWNX4.

Of course there may be problems with specific modules on wine - but these should be independent from the problem described above.

Once I have it working with MySQL I'll post here.
Test help welcome.

Setting up the binaries on wine is not more complicated than with the official NWN2 and NWNX4 distribution.

Just copy all the stuff in the directory in your wine environment, set up the ini files and then with

wine NWNX4_EXP_GUI

you would start it.

( I changed the executable and the dll file name to avoid confusion with the official distribution).

So - if you are able to set up MySQL and the NWNX4 Link on Windows, you can do it with the modified version as well.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
Darnah



Joined: 06 Jun 2007
Posts: 15

PostPosted: Wed Nov 21, 2007 16:08    Post subject: Reply with quote

My major problem is , that madcodehook doesn't work with 64bit systems. Because of this, i search for another solution.
I run NwN2 under a windows system, but i think, it will run under windows, when it works with wine.

I don't have any knowledge about compiling under windows and working with threads.
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Wed Nov 21, 2007 16:59    Post subject: Reply with quote

If you want i can send you the compiled binaries for testing. You'd just need 2 files: NWNX4_EXP_GUI.exe and NWNX4_EXP_hook.dll the other files you could take from the regular distribution.

Maybe just PM me an email addy and I'll send you a zip as attachment - or if you wish I'll set you up a temporary download link on my website.
_________________
/McKillroy
a.k.a Yorlik
Back to top
View user's profile Send private message
Darnah



Joined: 06 Jun 2007
Posts: 15

PostPosted: Wed Nov 21, 2007 19:36    Post subject: Reply with quote

First: The hook could be loaded within 64bit windows.
Now i will check, if database support works.
Back to top
View user's profile Send private message
mckillroy



Joined: 16 May 2005
Posts: 40

PostPosted: Wed Nov 21, 2007 20:59    Post subject: Reply with quote

Darnah wrote:
First: The hook could be loaded within 64bit windows.
Now i will check, if database support works.


This is awesome !

Detour doesn't yet have full 64 bit support, but if the hook could be loaded
it means the function we need is not affected by this.
If the hook dll loads and you see the IPC server working and the success message for the loaded hook functions the most crucial step has been done.

If a special plugin doesn't work this is another problem. If only one of the plugins works the basic stuff has been achieved.

Cheers
_________________
/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 -> Development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 3 of 6

 
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