Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing detours for hooking writing text in notepad
    primarykey
    data
    text
    <p>I'm trying to use detours to hook text output for example in notepad.</p> <p>I wrote the following code. I will not put here all code, but the most significant parts.</p> <p>DLL part:</p> <pre><code>DLLEXPORT LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode &lt; 0) { return CallNextHookEx(0, nCode, wParam, lParam); } if (nCode == HCBT_ACTIVATE) { HWND hWnd = (HWND)wParam; TCHAR szTemp[255]; GetWindowText(hWnd, szTemp, 255); DetourTransactionBegin(); DetourUpdateThread(hWnd); DetourAttach(&amp;(PVOID&amp;)Real_DrawText, Mine_DrawText); DetourTransactionCommit(); DetourTransactionBegin(); DetourUpdateThread(hWnd); DetourAttach(&amp;(PVOID&amp;)Real_DrawTextEx, Mine_DrawTextEx); DetourTransactionCommit(); DetourTransactionBegin(); DetourUpdateThread(hWnd); DetourAttach(&amp;(PVOID&amp;)Real_TextOut, Mine_TextOut); DetourTransactionCommit(); DetourTransactionBegin(); DetourUpdateThread(hWnd); DetourAttach(&amp;(PVOID&amp;)Real_ExtTextOut, Mine_ExtTextOut); DetourTransactionCommit(); } return 0; } </code></pre> <p>Client part:</p> <pre><code>int main(int argc, char* argv[]) { HOOKPROC hkprcSysMsg; static HINSTANCE hinstDLL; static HHOOK hhookSysMsg; hinstDLL = LoadLibrary(TEXT("dllsample.dll")); //cout &lt;&lt; (hinstDLL == NULL); hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "_CBTProc@12"); DWORD dw = GetLastError(); //cout &lt;&lt; (hkprcSysMsg == NULL); //cout &lt;&lt; dw; hhookSysMsg = SetWindowsHookEx( WH_CBT, hkprcSysMsg, hinstDLL, 0); //std::cout &lt;&lt; (hhookSysMsg == NULL); int i; std::cin &gt;&gt; i; } </code></pre> <p>The problem is that all 4 functions which draw text are not hooked. What do I do wrong. I'v started studing detours and didn't find answer for my question in docs.</p> <p>If other parts of code are required, I'll put them here later.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload