Folks,
I am trying out the scanner sample, and have made some modifications to it,
in my case the Message to the user is of constant length (that is there is
no buffer in it) and the user returns me a buffer filled with data. (this
is some sort of a reflector driver scenario where the kernel requests the
user with some data offlet and length and the user code fetches the data
from the source and furnishes the kernel with a buffer).
The problem is I constantly am getting error 122 from the API
GetQueuedCompletionStatus()
122 stands for “The data area passed to a system call is too small.”
This at first seemed very simple, but unfortunately I haven’t found out why
it complains.
Here are the structures with relevant parts of code:
In the worker thread:
bRes = GetQueuedCompletionStatus( pTPCtx->hCompletion,
&outSize,
&key,
&pOvlp,
INFINITE );
pMessage = CONTAINING_RECORD( pOvlp,
MY_REQUEST_TO_USERLAND_MESSAGE, Ovlp );
where MY_REQUEST_TO_USERLAND_MESSAGE is defined as:
typedef struct _MY_REQUEST_TO_USERLAND_MESSAGE {
FILTER_MESSAGE_HEADER MessageHeader;
MY_TRANSLATE_CONTEXT TranslationRequest;
OVERLAPPED Ovlp;
} MY_REQUEST_TO_USERLAND_MESSAGE, *PMY_REQUEST_TO_USERLAND_MESSAGE;
and MY_TRANSLATE_CONTEXT is :
typedef struct _MY_TRANSLATE_CONTEXT {
ULONGLONG uOffset;
ULONGLONG uLen;
} MY_TRANSLATE_CONTEXT, *PMY_TRANSLATE_CONTEXT;
Here is how in the driver I allocate for these structures:
ULONG uLenMsgToUser = sizeof(FILTER_MESSAGE_HEADER) +
sizeof(MY_TRANSLATE_CONTEXT) + sizeof(OVERLAPPED);
pMsgToUser =
(PMY_REQUEST_TO_USERLAND_MESSAGE)MyAllocateMemory(NonPagedPool,
uLenMsgToUser,
MY_READOP_POOL_TAG);
RtlZeroMemory(pMsgToUser, uLenMsgToUser);
pMsgToUser->TranslationRequest.uLen = TransCtx.uLen;
pMsgToUser->TranslationRequest.uOffset = TransCtx.uOffset;
ULONG uReplyLength = sizeof(FILTER_REPLY_HEADER) + sizeof(MY_REPLY_CONTEXT)
- TransCtx.uLen;
pReplyMsgFromUser = (PMY_REPLY_FROM_USERLAND_MESSAGE)MyAllocateMemory(
NonPagedPool,
uReplyLength,
MY_READOP_POOL_TAG);
RtlZeroMemory(pReplyMsgFromUser, uReplyLength);
status = FltSendMessage( g_MyData.Filter,
&g_MyData.ClientPort,
pMsgToUser,
uLenMsgToUser,
pReplyMsgFromUser,
&uReplyLength,
NULL );
I am unable to figure out why the user land thread complains. Can some one
please help…
regards
ami