Advertisement

11.19.2008 at 09:11AM PST, ID: 23918576 | Points: 500
[x]
Attachment Details

Unidriver OEMTextOut, wrong output characters

Asked by headsy in Microsoft Programming, Windows Programming, Kernel And Operating System Specific Programming

Tags:

I'm developing a windows printer driver, based on unidriver. One of the capabilities of the driver is to hook all text that is printed and send it directly to a file. This capability works ok with some printed documents, but with other documents (some pdf's, or printing from Firefox browser) I get scrambled text that doesn't make any sense. In attachment I will attach one pdf where I cannot get correct printed text.

I need to know how to get the right text, i.e., I want to have an string that's exactly what we can read when we open the pdf.

The attached code snippet works ok when printing the Print Test Page from Windows. All text output is readable.

Attached is one PDF that give the problem, and a output file that shows the text that DrvtextOut is getting.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
BOOL APIENTRY OEMTextOut(SURFOBJ* pso, STROBJ* pstro, FONTOBJ* pfo, CLIPOBJ* pco, RECTL* prclExtra, RECTL* prclOpaque, BRUSHOBJ* pboFore, BRUSHOBJ* pboOpaque, POINTL* pptlOrg, MIX mix )
{
	OEMDBG(DBG_VERBOSE, L"OEMTextOut entry.");
 
	write_log( 3, _T("OEMTextOut"), _T(""));
 
	ULONG	ulTextSize	;
	char*	AnsiText	;
	BOOL	iRes		= TRUE;
 
	if (pso == NULL || pstro == NULL || pfo == NULL)
		{
		OEMDBG(DBG_VERBOSE, L"\tInvalid parameters.");
		return FALSE;
		}
 
	PDEVOBJ		ppdev	= (PDEVOBJ)pso->dhpdev;
	POEMPDEV	pOemPDEV= (POEMPDEV)ppdev->pdevOEM;
 
	DWORD dwResult = 0;
	
	if (ppdev && pstro->pwszOrg != NULL)
		{
		//dwResult = ppdev->pDrvProcs->DrvWriteSpoolBuf(ppdev, (LPBYTE)"TextOut\r\n", 9);
		AnsiText = (char*)EngAllocMem(FL_ZERO_MEMORY, pstro->cGlyphs + 1, DRIVER_ID);
		if (AnsiText)
			{
			EngUnicodeToMultiByteN(AnsiText, stro->cGlyphs, &ulTextSize, pstro->pwszOrg, pstro->cGlyphs * sizeof(WCHAR));
			DWORD dwBufOffset = OemPDEV->textProc.dwBufSize;
 
			// Increase the buffer by the size of the current band
			if (!bGrowTextBuffer(pOemPDEV, strlen(AnsiText) + 2))
				{ 
				write_log( 1, _T("OEMTextOut"), _T(""));
				return E_FAIL;
				}
 
			CopyMemory((pOemPDEV->textProc.pBufStart + dwBufOffset), (LPBYTE)AnsiText, strlen(AnsiText));
			CopyMemory((pOemPDEV->textProc.pBufStart + dwBufOffset + strlen(AnsiText)), (LPBYTE)"\r\n", 2);
 
			write_log( 3, _T("OEMTextOut"), _T("%s"), pstro->pwszOrg);
			
			EngFreeMem(AnsiText);
			}
		}
 
	// Punt call back to UNIDRV.
	return (pOemPDEV->m_pfnDrvTextOut)(pso, pstro, pfo, pco, prclExtra, prclOpaque, pboFore, pboOpaque, pptlOrg, mix);
}
Attachments:
 
One of the PDF that shows the problem
 
 
trace file that shows the scrambled output
 
 
trace file (windows print test page) that shows that the OEMTextOut can actually do correct output
 
 
Loading Advertisement...
 
[+][-]11.20.2008 at 12:52PM PST, ID: 23008073

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.20.2008 at 01:05PM PST, ID: 23008213

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628