- ctx->readret = ReadFile(ctx->h, ctx->buffer, sizeof(ctx->buffer),
- &ctx->len, NULL);
+ if (povl) {
+ memset(povl, 0, sizeof(OVERLAPPED));
+ povl->hEvent = oev;
+ }
+ ctx->readret = ReadFile(ctx->h, ctx->buffer, readlen,
+ &ctx->len, povl);
+ if (povl && !ctx->readret && GetLastError() == ERROR_IO_PENDING) {
+ WaitForSingleObject(povl->hEvent, INFINITE);
+ ctx->readret = GetOverlappedResult(ctx->h, povl, &ctx->len, FALSE);
+ }
+