I'm quite new to WDK, I'm trying to create, a virtual printer driver which will send data to user application using named pipe. I'm using 'XPSDrv Driver and Filter Sample' as start. I've added new filter at the end in which I've put this client code:
HANDLE hPipe;
LPTSTR lpvMessage=TEXT("Message from UMDF!");
BOOL fSuccess = FALSE;
DWORD cbToWrite, cbWritten, dwMode;
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
hPipe = CreateFile(
lpszPipename,
//GENERIC_READ |
GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState(
hPipe,
&dwMode,
NULL,
NULL);
if (fSuccess)
{
cbToWrite = (lstrlen(lpvMessage)+1)*sizeof(TCHAR);
fSuccess = WriteFile(
hPipe,
lpvMessage,
cbToWrite,
&cbWritten,
NULL);
}
Code works for a Console Application project, but doesn't work inside UMDF printer driver. Server is also a Console Application which is started all the time. Does someone has idea why? Or maybe you know easy way how can I debug printer drivers?
All the best, Daniel