Friday, January 13, 2006 |
|
|
O
Lazy Web, I Invoke Thee:
I
am trying to call a function in a DLL that I’ve injected into an
arbitrary number of processes.
I
need to call a function on that instance of the DLL running in
the target process. So, I tried…
//hookedProcesses
== List<ProcessModule> as you’d expect
//myDll
== string initialized to path of my injected DLL, as you’d expect
//delegate
void VoidDelegate() as you’d expect
foreach(ProcessModule
process in hookedProcesses)
{
if(module.FileName == myDll)
{
IntPtr dllHandle = Interop.GetModuleHandle(filename); //Interop to Win32
GetModuleHandle()
IntPtr funcPtr = Interop.GetProcAddress(dllHandle, “MyFunction”);
//Interop to Win32 GetProcAddress()
VoidDelegate func = (VoidDelegate)
Marshall.GetDelegateForFunctionPointer(funcPtr, typeof(VoidDelegate));
// EVERYTHING WORKS TO THIS POINT.
func(); //ß
Causes segfault / “corrupted memory” error
What
I’m wondering is if I’m just ignorant of some Windows protection
feature that says “Hey, you can’t just go run functions across
process boundaries.”? Is there some obvious thing that I’m missing?
I almost wonder if I have to use some kind of mutex or somesuch to signal
across instances of the .DLL running in different processes?
|
Friday, January 13, 2006 6:28:29 PM (Hawaiian Standard Time, UTC-10:00) | Disqus link |
|
|
|
|
|
|
|
| Recently Published Articles |
|
|
|
|
|
|
|
| HI |
|
|
|
|
| Archive |
| September, 2008 (2) |
| August, 2008 (6) |
| July, 2008 (12) |
| June, 2008 (3) |
| May, 2008 (1) |
| April, 2008 (11) |
| March, 2008 (11) |
| February, 2008 (24) |
| January, 2008 (20) |
| December, 2007 (18) |
| November, 2007 (25) |
| October, 2007 (27) |
| September, 2007 (16) |
| August, 2007 (28) |
| July, 2007 (46) |
| June, 2007 (41) |
| May, 2007 (23) |
| April, 2007 (26) |
| March, 2007 (23) |
| February, 2007 (27) |
| January, 2007 (36) |
| December, 2006 (31) |
| November, 2006 (24) |
| October, 2006 (35) |
| September, 2006 (52) |
| August, 2006 (56) |
| July, 2006 (34) |
| June, 2006 (63) |
| May, 2006 (45) |
| April, 2006 (29) |
| March, 2006 (30) |
| February, 2006 (17) |
| January, 2006 (11) |
| December, 2005 (27) |
| November, 2005 (8) |
| October, 2005 (21) |
| September, 2005 (48) |
| August, 2005 (14) |
| July, 2005 (17) |
| June, 2005 (8) |
| May, 2005 (10) |
| April, 2005 (10) |
| March, 2005 (43) |
| February, 2005 (21) |
| January, 2005 (22) |
| December, 2004 (69) |
| November, 2004 (46) |
| October, 2004 (28) |
| September, 2004 (8) |
| August, 2004 (5) |
| July, 2004 (1) |
| June, 2004 (27) |
| May, 2004 (12) |
| April, 2004 (45) |
| March, 2004 (89) |
| February, 2004 (37) |
| January, 2004 (10) |
| December, 2003 (42) |
| November, 2003 (52) |
| October, 2003 (32) |
| September, 2003 (16) |
| August, 2003 (20) |
| July, 2003 (20) |
| June, 2003 (26) |
| May, 2003 (20) |
| April, 2003 (3) |
| March, 2003 (1) |
| February, 2003 (11) |
| January, 2003 (16) |
| December, 2002 (23) |
| November, 2002 (26) |
| October, 2002 (38) |
| September, 2002 (55) |
| August, 2002 (4) |
| July, 2002 (3) |
| June, 2002 (3) |
|
|
|
|