私は簡単なフックのlibを使用しています。所有者ウィンドウはどのように処理されますか?DrawTextフックの子供から親のHwdを取得
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public override string ToString()
{
return $"[Left: {Left}, Top: {Top}, Right: {Right}, Bottom: {Bottom}]";
}
}
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int DrawText(IntPtr hDc, string lpString, int nCount, ref Rect lpRect, uint uFormat);
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
public delegate int DDrawText(IntPtr hDc, string lpString, int nCount, ref Rect lpRect, uint uFormat);
private int DrawText_Hooked(IntPtr hDc, string lpString, int nCount, ref Rect lpRect, uint uFormat)
{
var This = (Main) HookRuntimeInfo.Callback;
lock (This._queue)
{
var parent = GetAncestor(hDc, GetAncestorFlags.GetParent); // always return 0! why????????????????
This._queue.Push($"parent [{parent}]");
}
return DrawText(hDc, lpString, nCount, ref lpRect, uFormat);
}
GetWindowDC、GetDC、GetParent関数およびその他の がどのように親ウィンドウを取得するには、あまりにも、何の作業ではありませんか?
GetAncestorは、ウィンドウハンドルが必要です。描画コンテキストを渡しています。描画コンテキストからウィンドウハンドルを取得するには、[GetWindowFromDC](https://msdn.microsoft.com/en-us/library/dd145201(VS.85).aspx)を呼び出します。 –
あなたは何をしようとしていますか? – andlabs
WindowFromDCは機能しません! –