I send a message to minidriver with following code, the minidriver can
receive the message sent from client, but the return result of the
FilterSendMessage is not S_OK, why
#include <windows.h>
#include <stdio.h>
#include <fltuser.h>
#define COMM_PORT_NAME L"\CommPort <file:></file:>“;
typedef enum _READ_DIR_COMMAND {
FStart
} READ_DIR_COMMAND;
struct READ_DIR_MESSAGE {
READ_DIR_COMMAND Command;
};
int main(int argc, char* argv)
{
HRESULT hResult = S_OK;
HANDLE port = INVALID_HANDLE_VALUE;
DWORD bytesReturned = 0;
READ_DIR_MESSAGE command;
TCHAR retcmd[10];
command.Command = FStart;
hResult = FilterConnectCommunicationPort(L”\CommPort <file:></file:>“,
0,NULL,0,NULL,&port );
if (IS_ERROR( hResult )) {
printf( “Could not connect to filter: 0x%08x\n”, hResult );
return 0;
}
else
{
printf(“connect ok \n”);
}
hResult = FilterSendMessage( port, &command, sizeof(READ_DIR_COMMAND),
retcmd, 10, &bytesReturned );
if (IS_ERROR( hResult )) {
printf(“Error”);
}
printf(”%l", bytesReturned);
return 0;
}</fltuser.h></stdio.h></windows.h>
The return value depends on your MessageNotifyCallback that you specify when calling FtlCreateCommunicationPort in your driver. If that is NULL then any data sent to the port will receive an error.
/Daniel
“峰姚” wrote in message news:xxxxx@ntfsd…
I send a message to minidriver with following code, the minidriver can receive the message sent from client, but the return result of the FilterSendMessage is not S_OK, why
#include <windows.h>
#include <stdio.h>
#include <fltuser.h>
#define COMM_PORT_NAME L"\CommPort";
typedef enum _READ_DIR_COMMAND {
FStart
} READ_DIR_COMMAND;
struct READ_DIR_MESSAGE {
READ_DIR_COMMAND Command;
};
int main(int argc, char* argv)
{
HRESULT hResult = S_OK;
HANDLE port = INVALID_HANDLE_VALUE;
DWORD bytesReturned = 0;
READ_DIR_MESSAGE command;
TCHAR retcmd[10];
command.Command = FStart;
hResult = FilterConnectCommunicationPort(L"\CommPort", 0,NULL,0,NULL,&port );
if (IS_ERROR( hResult )) {
printf( “Could not connect to filter: 0x%08x\n”, hResult );
return 0;
}
else
{
printf(“connect ok \n”);
}
hResult = FilterSendMessage( port, &command, sizeof(READ_DIR_COMMAND), retcmd, 10, &bytesReturned );
if (IS_ERROR( hResult )) {
printf(“Error”);
}
printf(“%l”, bytesReturned);
return 0;
}</fltuser.h></stdio.h></windows.h>