Pending and completing a device IO control request in RDBSS

I have been trying to completing a previously pended device IO control request utilising RDBSS and im always failing. Does anyone know how this process is actually done?

What i do in the service app is the following:

if ((DeviceHandle = CreateFile(DEVICEFILENAME,0,0,NULL,CREATE_NEW,FILE_FLAG_OVERLAPPED,NULL)) == INVALID_HANDLE_VALUE)
{
ull_errno = GetLastError();
return;
}
HANDLE OverlappedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

while (true)
{
ResetEvent(OverlappedEvent); // Reset Event always to non-signalled state

OVERLAPPED myOverlapped;
// set up overlapped structure fields
myOverlapped.Offset = 0;
myOverlapped.OffsetHigh = 0;
myOverlapped.hEvent = OverlappedEvent;

DWORD bytesReturned;
DWORD dataSize = sizeof(struct data);
struct data *myData;
myData = (struct data*)malloc(dataSize);
memset(myData, 0, dataSize);

myData->ulc_signature = HOBFSD_SIGNATURE;
iml_error = DeviceIoControl(DeviceHandle,
(DWORD)IOCTL_GET_REQ,
myData,
dataSize,
myData,
dataSize,
&bytesReturned,
&myOverlapped
);

DWORD lastError;
if (!iml_error)
{
switch (lastError = GetLastError())
{
case ERROR_IO_PENDING:
{
wprintf(L"Starting to WaitForSingleObject\n"); // <-------------- This is called
WaitForSingleObject(OverlappedEvent, INFINITE);

wprintf(L"Returned from WaitForSingleObject\n"); // <-------------- This is never called

if (bytesReturned != dataSize)
{
wprintf(L"bytesReturned != dataSize\n");
break;
}
else
{
// Complete request
OVERLAPPED completeOverlapped;
// set up overlapped structure fields
completeOverlapped.Offset = 0;
completeOverlapped.OffsetHigh = 0;
completeOverlapped.hEvent = 0;

iml_error = DeviceIoControl(DeviceHandle,
(DWORD)IOCTL_COMPLETE_REQ,
myData,
dataSize,
myData,
dataSize,
&bytesReturned,
&completeOverlapped);

wprintf(L"IOCTL_COMPLETE_REQ completed successfully\n");
}
break;
}
default:
{
wprintf(L"Unhandled case(%u)\n", lastError);
break;
}
}
}
}


What I assume I am not handling the pending IRP correctly in RDBSS! Can anyone help please?

I narrowed the problem down to the driver and the RDBSS! Can anyone explain how to complete a previously pending request utilising RDBSS? Help would be greatly appreciated!

Thanks in advance,
Matthew