hidden hit counter
Help!

InitializePrintMonitor2 in Language monitor

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Device Driver RSS
Next:  Eratic Mouse  
Author Message
DDKUser
External


Since: Jul 08, 2009
Posts: 1



PostPosted: Wed Jul 08, 2009 12:58 pm    Post subject: InitializePrintMonitor2 in Language monitor
Archived from groups: microsoft>public>windowsxp>device_driver>dev (more info?)

Hi,

We have a custom language monitor that we have been using for our printer.
It uses the old Monitor structure. We would like to use the Monitor2
structure and InitializePrintMonitor2. However when we install the driver the
spooler crashes when it tries to invoke OpenportEx() function for the
underlying port monitor from the language monitor's MyMonOpenportEx()
function. The crash occurs right between the first and the 2nd DbgPrint
statements in the MyMonOpenportEx() function. Some code snippets follow.

-------------------

MONITOR2 Monitor2 = {
sizeof(MONITOR2),
NULL,
NULL,
MyMonOpenPortEx,
MyMonStartDocPort,
MyMonWritePort,
MyMonReadPort,
MyMonEndDocPort,
MyMonClosePort,
NULL, /* AddPort */
NULL, /* AddPortEx */
NULL, /* ConfigurePort */
NULL, /* DeletePort */
MyMonGetPrinterDataFromPort, /* GetPrinterDataFromPort */
NULL,
NULL,
NULL,
NULL,
MyMonShutdown,
MyMonSendRecvBidiDataFromPort
};

LPMONITOR2
WINAPI
InitializePrintMonitor2(
IN PMONITORINIT pMonitorInit,
IN PHANDLE phMonitor)

{
if ( Is_Win2000( ) )
Monitor2.cbSize = MONITOR2_SIZE_WIN2K;

*phMonitor = (PHANDLE)pMonitorInit;
return &Monitor2;
}


BOOL
WINAPI
MyMonOpenPortEx(IN HANDLE hMonitor, //MONITOR2 only
IN HANDLE hMonitorPort,
IN LPTSTR pszPortName,
IN LPTSTR pszPrinterName,
IN OUT LPHANDLE pHandle,
IN OUT LPMONITOR2 pMonitor
)

{
PINIPORT pIniPort;
BOOL bRet = FALSE;
BOOL bInSem = FALSE;

//
// Validate port monitor
//
if ( !pMonitor ||
!pMonitor->pfnOpenPort ||
!pMonitor->pfnStartDocPort ||
!pMonitor->pfnWritePort ||
!pMonitor->pfnReadPort ||
!pMonitor->pfnClosePort )
{


SetLastError(ERROR_INVALID_PRINT_MONITOR);
goto Cleanup;
}

EnterSplSem();
bInSem = TRUE;

//
// Is the port open already?
//
if ( pIniPort = FindIniPort(pszPortName) ) {

SetLastError(ERROR_BUSY);
goto Cleanup;
}
pIniPort = CreatePortEntry(pszPortName);
LeaveSplSem();
bInSem = FALSE;

DbgPrint(1, "LangMon(%s):: MyMonOpenPortEx Before Port Monitor Open",
pszPrinterName);
if ( pIniPort &&
(*pMonitor->pfnOpenPort)(hMonitor, pszPortName, &pIniPort->hPort) )
{

DbgPrint(1, "LangMon(%s):: Port Monitor open Done", pszPrinterName);
*pHandle = pIniPort;
CopyMemory((LPBYTE)&pIniPort->fn, (LPBYTE)pMonitor,
sizeof(*pMonitor));

//Initialize Vars.
memset(pIniPort->statusBytes, 0, 50);
pIniPort->pszSavedPrnName = AllocSplStr(pszPrinterName);
pIniPort->bPSBAvailable = FALSE;
pIniPort->nStatusCnt = 0;
pIniPort->status &= ~PP_INSTARTDOC;
pIniPort->PrinterStatus = 0;
CreateUstatusThread(pIniPort);
bRet = TRUE;
}
else
{

bRet = FALSE;
}

Cleanup:
if ( bInSem ) {

LeaveSplSem();
}
SplOutSem();
return bRet;
}


---------------------

The language monitor worked fine with the older
Monitor/InitializePrintMonitor implementation. Any ideas/suggestions on what
we are not doing right here, would be greatly appreciated.

Thanks.
---
DDKUser
Back to top
daniel
External


Since: Jul 09, 2009
Posts: 1



PostPosted: Thu Jul 09, 2009 1:10 pm    Post subject: Re: InitializePrintMonitor2 in Language monitor [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

When you initialize the MONITOR2 structure you initialize the pfnOpenPort
function to NULL. If this is NULL it's not clear how this passed your
sanity check (if (...!pMonitor->pfnOpenPort)) however if it is not NULL you
should be able to step through your pfnOpenPort routine and see what this
does. Otherwise it's suggested you paste the debugger output of
!analyze -v

//Daniel



"DDKUser" <DDKUser DeleteThis @discussions.microsoft.com> wrote in message
news:E5556098-B1B5-47B7-8EA1-6C8B7F8E25D4@microsoft.com...
> MONITOR2 Monitor2 = {
> sizeof(MONITOR2),
> NULL,
> NULL,
> MyMonOpenPortEx,
......
>
> //
> // Validate port monitor
> //
> if ( !pMonitor ||
> !pMonitor->pfnOpenPort ||
> !pMonitor->pfnStartDocPort ||
> ....
>
.......
> (*pMonitor->pfnOpenPort)(hMonitor, pszPortName,
> &pIniPort->hPort) )
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Device Driver All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum