-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LocalHook.Create throwing AccessViolationException #47
Comments
Are you injecting into another process? The problem appears to be less EasyHook specific, and more about the environment you are working within.
|
Can you try using manual calls to |
Yeah, this is what I did: IntPtr hand = GetModuleHandle(dll); With log statements after each one. The only one that failed was the Create call. Thanks for the responses. |
@arshrp sorry for the long delay, did the LocalHook.Create work for you when specifying the address using the manual call to GetProcAddress? If so I am thinking of closing this issue, otherwise I may need a simple sample app to test properly. |
Hi EasyHookers,
Your product is working wonderfully for us in most situations. But we are experiencing an issue on Windows 2008 Terminal Services machine. The call to GetProcAddress is throwing this exception:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at EasyHook.LocalHook.Create(IntPtr InTargetProc, Delegate InNewProc, Object InCallback)
Your documentation clearly states that this exception will be thrown when "Access to target process denied or the current user is not an administrator", but we are running our application as an administrator (using the "Run as administrator" File Manager menu option), so it should have the necessary permissions.
Below is a summary of the code we are using. Are we doing anything wrong that might cause this error? ANY suggestions at all that you can provide would be most appreciated!
Andrew
public class Injector : EasyHook.IEntryPoint {
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)]
delegate bool DExtTextOutW(IntPtr hdc, int X, int Y, uint fuOptions, IntPtr lprc, IntPtr lpString, uint cbCount, IntPtr lpDx);
public void InstallHook(NxKitInterface iface) {
LocalHook.Create(
LocalHook.GetProcAddress("Gdi32.dll", "ExtTextOutW"),
new DExtTextOutW(ExtTextOutW_Hooked),
this
);
}
static bool ExtTextOutW_Hooked(IntPtr hdc, int X, int Y, uint fuOptions, IntPtr lprc, IntPtr lpString, uint cbCount, IntPtr lpDx) {
}
}
The text was updated successfully, but these errors were encountered: