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
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Mon Jan 01, 2007 16:15    Post subject: Reply with quote

Madcodehook does something very similar. Since it is supposed to work with Vista as well, nothing was really changed here. IIRC, not all processes can write to the code section of foreign processes, and for example under Linux, you have to unprotect it before writes are allowed.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
chaoslink



Joined: 23 Aug 2006
Posts: 37

PostPosted: Mon Jan 01, 2007 19:42    Post subject: Reply with quote

Papillon wrote:
Madcodehook does something very similar. Since it is supposed to work with Vista as well, nothing was really changed here. IIRC, not all processes can write to the code section of foreign processes, and for example under Linux, you have to unprotect it before writes are allowed.


What he said.
Back to top
View user's profile Send private message
smellysocks



Joined: 05 Jan 2007
Posts: 3
Location: Toronto, Canada

PostPosted: Fri Jan 05, 2007 15:06    Post subject: Reply with quote

So, not to beat a dead horse, but is there anything in the way of 64 bit support?

I mean a beta hook, or anything at all that works?

Does anyone have any other solution at all?
Back to top
View user's profile Send private message Visit poster's website
chaoslink



Joined: 23 Aug 2006
Posts: 37

PostPosted: Fri Jan 05, 2007 21:27    Post subject: Reply with quote

not in what I'm doing at all... if Microsoft has a 64 bit version of detours, with source available like the 32 bit version, then what I'm working on may be of some use.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Jan 06, 2007 15:52    Post subject: Reply with quote

I was promised a 64-bit enabled version of madcodehook by it's author, but haven't received anything yet. Guess I have to ping him again...
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Sun Apr 08, 2007 0:05    Post subject: Reply with quote

Hello, Papillon.
I'm writing AssemblyHelper class that can find a function by its signature:
Code:
*(dword*)&pGetFaction =   asmhelp.FindFunctionBySignature("55 89 E5 56 53 ** ** ** 8D 45 F4 50 8B 55 0C");

Upcoming features are: hooking and making a hook queue to allow multiple plugins to hook the same function.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Mon Apr 09, 2007 22:30    Post subject: Reply with quote

I've recently written a similar function that finds the NWNX functions OE gave us in NWN2. But what I am missing is a way to load a DLL into the server process space, like LD_PRELOAD does on Linux.

Is there a way to do this without madcodehook ? I haven't done any research on this, but maybe someone knows more ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Apr 09, 2007 23:34    Post subject: Reply with quote

Papillon wrote:
I've recently written a similar function that finds the NWNX functions OE gave us in NWN2. But what I am missing is a way to load a DLL into the server process space, like LD_PRELOAD does on Linux.

Is there a way to do this without madcodehook ? I haven't done any research on this, but maybe someone knows more ?

My understanding is...
Now that the NWNX functions have been exposed (exported?) you can now use the Windows API hooking functions directly [kernal32]. (previously you were hooking into a code address).
MCH is a common wrapper around several hooking mechanisms. The windows API amongst them.

It's all available on MSDN

Cheers
Gryphyn
Back to top
View user's profile Send private message
dumbo



Joined: 21 Aug 2005
Posts: 21

PostPosted: Tue Apr 10, 2007 2:50    Post subject: Reply with quote

sample of inject code:
Code:

  invoke    OpenProcess, PROCESS_ALL_ACCESS, 1, PID ; pid of nwserver.exe
  mov       ebx, eax
  invoke    VirtualAllocEx, ebx, 0, dllnamesize, MEM_COMMIT, PAGE_READWRITE
  mov       esi, eax
  invoke    WriteProcessMemory, ebx, esi, offset dllname, dllnamesize, 0
  invoke    GetModuleHandleA, offset szKernel32name ; 'kernel32.dll',0
  invoke    GetProcAddress, eax, offset szLoadLibrary ; 'LoadLibraryA',0
  invoke    CreateRemoteThread, ebx, 0, 0, eax, esi, 0, 0
  mov       edi, eax
  invoke    WaitForSingleObject, eax, INFINITE
  invoke    CloseHandle, edi
  invoke    CloseHandle, ebx


but in our case the simplest way(and the most correct) is to call CreateProcess (nwserver.exe) with CREATE_SUSPENDED flag or even DEBUG_PROCESS(gives us exception control, for example). patch process memory and ResumeThread.

ps. i'm sorry for my russian-english. i want to help you guys, but rl/work burn my time.
Back to top
View user's profile Send private message
Grinning Fool



Joined: 12 Feb 2005
Posts: 264

PostPosted: Wed Apr 11, 2007 4:46    Post subject: Reply with quote

Gryph- those will only help to load a DLL into the current process, but not into an external process.

I seemed to recall that ther was a registry key that can be used to preload a DLL into every proc automatically. Some digging found the key, but it odes preload for /all/ processes, so is probably overkill:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs
Source: http://www.stanford.edu/~stinson/misc/curr_res/hooks/api_spy.txt


Outside of that, it looks like this will be your best bet:
http://www.codeproject.com/dll/DLL_Injection_tutorial.asp
_________________
Khalidine, a NWN2 persistent world

Looking for volunteers.
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Wed Apr 11, 2007 6:45    Post subject: Reply with quote

Maybe here as well

Cheers
Gryphyn
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun Apr 15, 2007 14:23    Post subject: Reply with quote

Thanks for those pointers guys, I'll look into them.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
MagnumMan



Joined: 01 Apr 2005
Posts: 8
Location: MA

PostPosted: Mon Apr 30, 2007 14:28    Post subject: Reply with quote

Why don't you just ask madshi for the 64-bit compabitle madCHook.DLL? Amia is running on Win64 with it just fine...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Mon Apr 30, 2007 22:02    Post subject: Reply with quote

I did, mutiple times, but got nothing. Madcodehook should be a thing of the past as far as NWNX is concerned anyway, so it does not matter.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun May 06, 2007 12:19    Post subject: Reply with quote

Update: I've got this to a point where NWNX4 can work without madcodehook, by doing the hooking on my own.

Unfortunately, I have to start a new thread in the server process to load my DLL, and this means that I can not use the DDE based IPC anymore (you can't have the same DDE connection in more than one thread). I will have to find other means to pass the nwnx base directory and the init command to the server. Maybe something like #pragma data_seg.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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 2 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