Note that there are some explanatory texts on larger screens.

plurals
  1. POHooking GetSysColor in user32.dll
    text
    copied!<p>I have a problem hooking the "GetSysColor" function of "user32.dll" in order to modify </p> <pre><code>COLOR_ACTIVECAPTION COLOR_CAPTIONTEXT COLOR_INACTIVECAPTION COLOR_INACTIVECAPTIONTEXT </code></pre> <p>My windows hook class looks like this:</p> <pre><code>CHook(const TCHAR * module, const TCHAR * procname, const void * pNewProc) { HINSTANCE hMod = GetModuleHandle(module); m_pProc = (BYTE*)GetProcAddress(hMod, procname); if (m_pProc) { for (int i = 0; i &lt; 5; i++) { m_Storage[i] = m_pProc[i]; } DWORD dwOldProtect; VirtualProtect(m_pProc, 5, PAGE_EXECUTE_READWRITE, &amp; dwOldProtect); m_pProc[0] = 0xE9; *(unsigned*)(m_pProc + 1) = (unsigned)pNewProc - (unsigned)(m_pProc + 5); } } ~CHook() { if (m_pProc &amp;&amp; (m_pProc[0] == 0xE9)) { for (int i = 0; i &lt; 5; i++) { m_pProc[i] = m_Storage[i]; } } } private: BYTE* m_pProc; BYTE m_Storage[5]; </code></pre> <p>I wrote a custom getsyscolor method</p> <pre><code>static COLORREF WINAPI GetCustomSysColor(int nIndex) { return RGB(0xFF, 0x00, 0x00); } </code></pre> <p>to test, if every message gets routed through that function (everything should be red at the end then). I installed it via</p> <pre><code>CHook theHook("user32.dll", "GetSysColor", GetCustomSysColor); </code></pre> <p>Unfortunately, not everything gets painted red, only a few things like icons etc. But the colors mentioned at the beginning are the former system settings - captions are still drawn blue with white text. I even debugged it and the colors for caption arrive in the GetCustomSysColors method.</p> <p>Maybe anybody knows if there is another winapi call going on for the caption or if I missed anything important. Thank you very much!</p> <p>Cheers, Chris</p>
 

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