I've got kernel mode driver which handles user-mode requests asynchronously. Maximum number of requests in the queue, lats say, 32. All the following requests are completed with STATUS_INSUFFICIENT_RESOURCE status. I need to check in user-mode app if the requests was completed with this status. That's my user-mode app code:
HANDLE hEvents[40] = { 0 };
OVERLAPPED ovls[40] = { 0 };
int index = 0;
while (true)
{
hEvents[index] = CreateEvent(NULL, FALSE, FALSE, NULL);
ZeroMemory(&ovls[index], sizeof(OVERLAPPED));
ovls[index].hEvent = hEvents[index];
BOOL res = DeviceIoControl(hDevice, SEND_REQUEST_CTL, nullptr, 0,
nullptr, 0, &dwBytesRet, &ovls[index]);
++index;
if (res == FALSE)
{
DWORD err = GetLastError();
if (err != ERROR_IO_PENDING)
{
WaitForMultipleObjects(index, hEvents, TRUE, INFINITE);
for (int i = 0; i < index; ++i)
CloseHandle(hEvents[i]);
}
}
}
I have array of hEvents and array of OVERLAPPED structures, because I need to wait for requests completion. So I the idea is that when driver returns STATUS_INSUFFICIENT_RESOURCE I just waiting for completion of all the IRPs that were queued to driver. The problem is in that even when driver calls
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCE;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, 0);
GetLastError()
from user-mode app returns ERROR_IO_PENDING so I can't handle STATUS_INSUFFICIENT_BUFFER driver error.
So my question is how can I check in user-mode app, that IRP was completed with STATUS_INSUFFICIENT_RESOURCE status?