in misc/VeryLargeRead.cc [67:122]
int main(int argc, char *argv[]) {
long long width = 9000;
long long height = 9000;
assert(argc >= 1);
if (argc == 4) {
width = atoi(argv[2]);
height = atoi(argv[3]);
} else {
if (argc == 3) {
width = atoi(argv[1]);
height = atoi(argv[2]);
}
wchar_t args[1024];
swprintf(args, 1024, L"CHILD %lld %lld", width, height);
startChildProcess(args);
return 0;
}
const HANDLE conout = GetStdHandle(STD_OUTPUT_HANDLE);
setWindowPos(0, 0, 1, 1);
setBufferSize(width, height);
setWindowPos(0, 0, std::min(80LL, width), std::min(50LL, height));
setCursorPos(0, 0);
printf("A");
fflush(stdout);
setCursorPos(width - 2, height - 1);
printf("B");
fflush(stdout);
trace("sizeof(CHAR_INFO) = %d", (int)sizeof(CHAR_INFO));
trace("Allocating buffer...");
CHAR_INFO *buffer = new CHAR_INFO[width * height];
assert(buffer != NULL);
memset(&buffer[0], 0, sizeof(CHAR_INFO));
memset(&buffer[width * height - 2], 0, sizeof(CHAR_INFO));
COORD bufSize = { width, height };
COORD bufCoord = { 0, 0 };
SMALL_RECT readRegion = { 0, 0, width - 1, height - 1 };
trace("ReadConsoleOutputW: calling...");
BOOL success = ReadConsoleOutputW(conout, buffer, bufSize, bufCoord, &readRegion);
trace("ReadConsoleOutputW: success=%d", success);
assert(buffer[0].Char.UnicodeChar == L'A');
assert(buffer[width * height - 2].Char.UnicodeChar == L'B');
trace("Top-left and bottom-right characters read successfully!");
Sleep(30000);
delete [] buffer;
return 0;
}