【发布时间】:2013-09-25 00:56:16
【问题描述】:
我正在 c# 中进行 dll 注入软件,注入的 dll 也在 c# 中,并且我正在将 pinvoke 用于某些系统功能。
当使用 extTextOut 时,我得到了字符串加扰并且行混合在一起 我做错了什么?
我使用来自 codeplex.com 的 EasyHook 连接了 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
);
}
如果可以,还有一个问题。如何持续监控失焦或最小化的窗口(使用这种方法无法正常工作)
非常感谢!
【问题讨论】:
标签: c# hook gdi dll-injection easyhook