Dears,
I've got a DLL for injection. This is injected via CBT-hook. Now, when the desired process is encountered via CBT, I've detoured WinAPI's ExtTextOutW with my own. The specification of ExtTextOutW is:
BOOL ExtTextOutW(HDC hdc,
INT x,
INT y,
UINT flags,
const RECT* lprect,
LPCWSTR str,
UINT count,
const INT* lpDx)
In my detoured ExtTextOutW i'm trying to convert str (LPCWSTR) to multibyte with the following code:
BOOL Mine_ExtTextOutW(HDC hdc,
INT x,
INT y,
UINT flags,
const RECT* lprect,
LPCWSTR str,
UINT count,
const INT* lpDx)
{
BOOL rv = Real_ExtTextOutW(hdc, x, y, flags, lprect, str, count, lpDx);
HANDLE h = ::WindowFromDC(hdc);
if (!h || !str)
return ev;
CHAR *buffer = (CHAR *)::LocalAlloc(count + 1);
int l = ::WideCharToMultiByte(CP_APC, 0, str, count, buffer, count, NULL, NULL);
if (l > -1) {
buffer[l] = '\0';
g_pClient->SendViaIPC(buffer);
}
::LocalFree(buffer);
return rv;
}
Unfortunately, this doesn't work. WideCharToMultiByte hangs the injected process. Why?