0
我正在c#中注入dll软件,注入的dll也在c#中,并且我正在使用某些系统函数的pinvoke。挂钩extTextOut问题
当使用extTextOut我得到的字符串炒和行混合在一起 我做错了什么?
try
{
CreateFileHook = LocalHook.Create(
LocalHook.GetProcAddress("gdi32.dll", "ExtTextOutW"),
new DExtTextOutW(ExtTextOutW_Hooked),
this);
CreateFileHook.ThreadACL.SetExclusiveACL(new Int32[1]);
}
和我extTextOut方法是
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
static extern bool ExtTextOutW(IntPtr hdc,
int X,
int Y,
uint fuOptions,
[In] ref RECT lprc,
string lpString,
uint cbCount,
[In] IntPtr lpDx);
static bool ExtTextOutW_Hooked(
IntPtr hdc,
int X,
int Y,
uint fuOptions,
[In] ref RECT lprc,
string lpString,
uint cbCount,
[In] IntPtr lpDx)
{
try
{
DemoInjection This = (DemoInjection)HookRuntimeInfo.Callback;
lock (This.Queue)
{
This.Queue.Push(lpString);
}
}
catch
{
}
return ExtTextOutW(
hdc,
X,
Y,
fuOptions,
ref lprc,
lpString,
cbCount,
lpDx
);
}
如果另外一个问题我可能:
我extTextOut使用EasyHook从codeplex.com这样的大呼过瘾。我怎样才能经常监控一个没有聚焦或最小化的窗口(使用这种方法它不能正常工作)
非常感谢!
现在我正在经历同样的问题。即使当我只是将参数传递给ExtTextOutW函数时,我仍然在挂钩程序中遇到问题 - 它显示了一些象形文字而不是拉丁文本。我相信,问题在于MarshalAs在转换为CLR字符串时会更改源数据中的某些内容。只有在设置了字形标志时,问题才会显示,否则,钩子可以正常工作,并且挂钩文本不会损坏。 – 2013-01-14 12:55:52