【发布时间】:2010-07-02 08:49:23
【问题描述】:
我已经将我的 DLL 注入到一个目标应用程序中,在该应用程序中我已经挂钩了几个 WINAPI 函数 也是。其中之一是 DrawTextExW。我正在尝试将所有“l”字母替换为“!”前 它打印出来。我的解决方案可以正常工作几秒钟,但随后目标应用程序崩溃。我真的不明白为什么。
函数如下:
编辑 - 工作解决方案:
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);
}
那么,谁能指出我做错了什么?
【问题讨论】: