Hello Team,
I am hooking ExtTextOutW to get a text from the notepad application. But the notepad text gets as GLYPH char.
notepad Input: 123456789123456789 Please look image here.
The above text converts it in to below GLYPH.
lpString = L"\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c"
Please look below the code for hooking API and parse GLYPH a text. During the parsing, it not return as my input text. Please let me know what is missing here.
BOOL ExtTextOutWHook(
HDC hdc,
int x,
int y,
UINT options,
const RECT *lprc,
LPCWSTR lpString,
UINT c,
const INT *lpDx
)
{
bool isGlyphIndex = ((options & ETO_GLYPH_INDEX) == ETO_GLYPH_INDEX);
if (isGlyphIndex)
{
DWORD dwSize = GetFontUnicodeRanges(hdc, nullptr);
BYTE* bBuffer = new BYTE[dwSize];
GLYPHSET* pGlyphSet = reinterpret_cast<GLYPHSET*>(bBuffer);
GetFontUnicodeRanges(hdc, pGlyphSet);
wchar_t *text = new wchar_t[c];
for (int i = 0; i < c; i++)
{
wchar_t glyph = lpString[i];
if (glyph < pGlyphSet->cRanges)
{
if (pGlyphSet->ranges[glyph].cGlyphs !=0)
{
text[i] = (pGlyphSet->ranges[glyph].wcLow);
}
else
{
text[i] = 32;
}
}
else
{
text[i] = glyph;
}
}
delete[] bBuffer;
}
return ExtTextOutW(hdc, x, y, options, lprc, lpString, c, lpDx);
}