I have injected my DLL into a target application where I've hooked few WINAPI-functions as well. One of them is DrawTextExW. I'm trying to replace all 'l' letters to '!' before it prints it out. My solution works fine for a few seconds, but then the target application crashes. I really don't understand why.
Here's the function:
Edit - Working solution:
int WINAPI DetouredDrawTextExW(__in HDC hdc,
__inout LPWSTR lpchText,
__in int cchText,
__inout LPRECT lprc,
__in UINT dwDTFormat,
__in LPDRAWTEXTPARAMS lpDTParams)
{
std::wstring s_wc(lpchText, cchText);
std::replace(s_wc.begin(), s_wc.end(), L'l', L'!');
return ::DrawTextExW(hdc, const_cast<wchar_t *>(s_wc.c_str()),
s_wc.length(), lprc, dwDTFormat, lpDTParams);
}
So, can somebody point it out to me what I'm doing wrong?