eric pouech (@epo) commented about dlls/kernelbase/console.c:
{
- if (!size) return 0;
struct condrv_title_params *params;
size_t max_size = sizeof(*params) + size * sizeof(WCHAR);
if (!title || !size) return 0;
if (!(params = HeapAlloc( GetProcessHeap(), 0, max_size )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return 0;
}
if (!console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE,
NULL, 0, title, (size - 1) * sizeof(WCHAR), &size ))
&size, sizeof(size), params, max_size, &size ))
you could even simplify further by not passing &size as an input parameter to the ioctl (the information is redundant with the output buffer size)
you can compute the expected size on conhost side from the expected output butffer size (see IOCTL_CONDRV_PEEK as an example)