I got this callback function that reads output from CreateThread and outputs it to the console
DWORD grabOutput(LPVOID lpParam )
{
BOOL success = FALSE;
DWORD dwRead, total =0;
char buffer[1024];
while(1)
{
success = ReadFile(Child_out_Read, buffer, 1024, &dwRead, NULL);
if (!success) break;
printf("%s",buffer);
}
return 0;
}
when a non-ascii character passed through printf it results in such format ???? this is because the encoding used does not contain the string passed or at least this is what I understand, for example if the Шифрование is read into the buffer this word results in the undefined format of question marks, I know the functions ending with A use the ANSI encoding and the one ending with W use the unicode but there is only ReadFile and ReadFileEx
Output
09/15/2022 11:13 AM 2,560 main.c
09/15/2022 08:32 AM <DIR> ???????
09/15/2022 08:34 AM 0 ??????????.txt
when using a loop and outputting each character using %04X %c I get
003F ?
003F ?
003F ?
003F ?
003F ?
003F ?
003F ?
003F ?
003F ?
003F ?
002E .
0074 t
0078 x
0074 t
How to deal with such problem once and for all so that it outputs any language to the screen

