Hooking ExtTextOut returns unexpected results
我试图将dll注入软件中,以绕过它的ExtTextOut函数。 注入和绕行效果很好(我正在使用Microsoft Detours),但是当我尝试修改ExtTextOut函数时,一切都会出错。
这是我的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #pragma comment(lib,"detours.lib") #include <Windows.h> #include <detours.h> #include <tchar.h> BOOL (WINAPI * Real_ExtTextOutW)(HDC hdc, int x, int y, UINT fuOptions, const RECT *lprc, LPCWSTR lpString, UINT cbCount, const INT *lpDx) = ExtTextOutW; BOOL WINAPI Mine_ExtTextOutW(HDC hdc, int x, int y, UINT fuOptions, const RECT *lprc, LPCWSTR lpString, UINT cbCount, const INT *lpDx) { // The expected results would be that every characters displayed become"z" return Real_ExtTextOutW(hdc, x, y, fuOptions, lprc, L"z", 1, lpDx); } BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourAttach(&(PVOID&)Real_ExtTextOutW, Mine_ExtTextOutW); DetourAttach(&(PVOID&)Real_DrawTextW, Mine_DrawTextW); DetourTransactionCommit(); break; case DLL_PROCESS_DETACH: DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourDetach(&(PVOID&)Real_ExtTextOutW, Mine_ExtTextOutW); DetourDetach(&(PVOID&)Real_DrawTextW, Mine_DrawTextW); DetourTransactionCommit(); break; } return TRUE; } |
因此,正如您在" Mine_ExtTextOut"中看到的那样,我正在尝试替换由" z"显示的每个字符或字符串。 但是,当我在各种软件上尝试时,结果如下所示:
那么...为什么ExtTextOut会在各处绘制随机字符而不是字母" z"?
最终,我的目标是能够检索显示的文本并进行分析以了解其显示位置,但是我认为从能够修改其显示方式开始是一个不错的开始...
检查
大多数文本绘图功能最终都由Uniscribe处理并翻译("定型")为一系列字形,然后使用
我怀疑如果绕道
您可能必须弄清楚如何从字形向后退到文本。