텍스트를 DirectX 게임에 그려야하므로 EndPaint를 후킹하는 DLL을 삽입했습니다. 내 논리는 EndPaint가 WM_PAINT 연산의 마지막 단계이기 때문에, 필자가 직접 텍스트를 그린 다음 EndPaint를 직접 호출 할 수 있었다. 이렇게하면 DX 인터페이스를 완전히 피할 수 있습니다.DirectX 창에 텍스트를 그리는 EndPaint 후킹
문제는 전혀하지 않는 것입니다. 여기 내 코드가있다.
#include <windows.h>
#include "Hooks.h"
static const TCHAR g_cszMessage[] = TEXT("utterly fantastic");
BOOL (WINAPI * _EndPaint)(__in HWND hWnd, __in const LPPAINTSTRUCT lpPaint) = EndPaint;
BOOL WINAPI EndPaintHook(__in HWND hWnd, __in const LPPAINTSTRUCT lpPaint)
{
// write message
TextOut(lpPaint->hdc, 0, 0, g_cszMessage, lstrlen(g_cszMessage));
GdiFlush();
// return original
return _EndPaint(hWnd, lpPaint);
}
BOOL APIENTRY DllMain(__in HINSTANCE hModule, __in DWORD fdwReason, __in __reserved LPVOID lpvReserved)
{
UNREFERENCED_PARAMETER(lpvReserved);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
if (AttachHook(reinterpret_cast<PVOID*>(&_EndPaint), EndPaintHook))
{
DisableThreadLibraryCalls(hModule);
break;
}
return FALSE;
case DLL_PROCESS_DETACH:
DetachHook(reinterpret_cast<PVOID*>(&_EndPaint), EndPaintHook);
break;
}
return TRUE;
}
는 내가 메시지 상자를 통해 테스트 후크가 설치되어 있음을 확인했기 때문에 문제가 내 AttachHook
/DetachHook
기능하지 알고있다. 텍스트가 단순히 나타나지 않습니다.
누구든지 아이디어가 있으십니까? DX 인터페이스를 연결하고 싶지 않습니다. WM_PAINT는 여전히 기본 레벨에서 사용되기 때문에 어떤 방식 으로든 작동하지 않아야합니까?
미리 감사드립니다.