Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


printer driver retrieving filename

sduffsduff Member Posts: 77
From what I've read on http://www.osronline.com/showThread.cfm?link=19117, Ashwin answered the fact that the printer driver/rendering plugin cannot retrieve the output filename. But I'm not sure about why that can't be done easily within the printer driver programmatically. Is it b/c the functionality of the rendering plugin is only responsible for rendering the image, whereas a custom print processor or language/port monitor is responsible for the output processing?

Comments

  • sduffsduff Member Posts: 77
    To further clear up my problem, I was trying to acquire the output filename from the DOCINFO structure passed in a test app when calling StartDoc(...) in the virtual printer driver. According to Ashwin's reply on that link, it's not possible to do so. However, I have tested using PDF Tools' printer driver and that printer driver managed to access the DOCINFO structure somehow and save the file to the intended location. Is there a specific function/methodology that I'm overlooking to achieve what I wanted to do?
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    I had tried for this and failed. I was unable to find out how to get that file name. After lot of readings we had concluded that it is not possible to get the same.

    -Srikanth


    ________________________________

    From: [email protected] on behalf of [email protected]
    Sent: Fri 6/27/2008 3:44 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] printer driver retrieving filename



    To further clear up my problem, I was trying to acquire the output filename from the DOCINFO structure passed in a test app when calling StartDoc(...) in the virtual printer driver. According to Ashwin's reply on that link, it's not possible to do so. However, I have tested using PDF Tools' printer driver and that printer driver managed to access the DOCINFO structure somehow and save the file to the intended location. Is there a specific function/methodology that I'm overlooking to achieve what I wanted to do?

    ---
    NTDEV is sponsored by OSR

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,378
    On Fri, Jun 27, 2008 at 05:02:30PM -0400, [email protected] wrote:
    > From what I've read on
    > http://www.osronline.com/showThread.cfm?link=19117, Ashwin answered the
    > fact that the printer driver/rendering plugin cannot retrieve the output
    > filename. But I'm not sure about why that can't be done easily within
    > the printer driver programmatically. Is it b/c the functionality of the
    > rendering plugin is only responsible for rendering the image, whereas a
    > custom print processor or language/port monitor is responsible for the
    > output processing?

    It's because a file in the print spool is just a stream of printer
    commands. They don't necessary have ANYTHING to do with a file or a
    file name. Some application might have produced the spool file from
    the contents of another file, but that information ins not part of
    the spool file.
    --
    Tim Roberts, [email protected]
    Providenza & Boeklheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    If this is for situations where "..user has chosen to 'Print to
    file'..." you should be able to read this information from the UI plugin
    when hooking StartDoc, you could then relay it to the rendering plugin
    by storing it in the DEVMODE struc or some other way

    /christoph



    > -----Original Message-----
    > From: [email protected] [mailto:bounce-328476-
    > [email protected]] On Behalf Of [email protected]
    > Sent: Friday, June 27, 2008 11:03 PM
    > To: Windows System Software Devs Interest List
    > Subject: [ntdev] printer driver retrieving filename
    >
    > From what I've read on
    http://www.osronline.com/showThread.cfm?link=19117,
    > Ashwin answered the fact that the printer driver/rendering plugin
    cannot
    > retrieve the output filename. But I'm not sure about why that can't be
    > done easily within the printer driver programmatically. Is it b/c the
    > functionality of the rendering plugin is only responsible for
    rendering
    > the image, whereas a custom print processor or language/port monitor
    is
    > responsible for the output processing?
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > For our schedule of WDF, WDM, debugging and other seminars visit:
    > http://www.osr.com/seminars
    >
    > To unsubscribe, visit the List Server section of OSR Online at
    > http://www.osronline.com/page.cfm?name=ListServer
  • sduffsduff Member Posts: 77
    Thanks for the explanations. I do have a follow up question to Christoph's reply: after looking at the DEVMODE structure description in the DDK documentations, I am having trouble finding parameters that look highly likely to contain output filename/filepath. How easy would it be to implement a print processor/monitor (even though the functionality of the printer driver that i'm working on seems to be a print processor as well, as it's converting from emf spooler file to another format that I want) that would save the output file to the appropriate desired location?
  • sduffsduff Member Posts: 77
    After doing more fishing in the DDK documentation in the document explorer, I found that DOCINFO structure can be accessed through a pointer in DrvDocumentEvent callback in DOCUMENTEVENT_STARTDOC flag option for iEsc (imo, I think the DOCINFO access methodogy should be documented in a more obvious place in the DDK documentation). Thanks for all your suggestions.
  • sduffsduff Member Posts: 77
    Sorry for the third consecutive email on this topic. I probably should've tested the DrvDocumentEvent callback with accessing the DOCINFO structure before posting the last email. Basically this is what I have so far in my attempt to access the filename from the DOCINFO structure passed by the StartDoc function called in the client application (the code below is in the interface application of the printer driver):

    wstring outputfp; // <- this is a global variable in the ui.cpp file

    INT DrvDocumentEvent(
    HANDLE hPrinter,
    HDC hdc,
    int iEsc,
    ULONG ulcIn,
    PVOID pulIn, //PULONG pulIn,
    ULONG ulcOut,
    PVOID pulOut //PULONG pulOut
    )
    {

    switch(iEsc)
    {
    ...
    case DOCUMENTEVENT_STARTDOC: // aka DOCUMENTEVENT_STARTDOCPRE
    DEBUGMESSAGE(("DrvDocumentEvent - STARTDOC"));

    // obtain DOCINFO here?
    tempDI = (DOCINFO *) pulIn;
    outputfp = wstring(tempDI->lpszDocName);

    break;
    ...
    }
    }

    I found that pulIn contains very different contents (i.e. blank, but not invalid pointer) from the DOCINFO that I passed in StartDoc in the client test application. What fundamentally am I doing improperly on my DOCINFO structure pointer that I have obtained in this case scenario?
  • sduffsduff Member Posts: 77
    As of now, I have managed to access DOCINFO structure inside DrvDocumentEvent before DrvStartDoc. However, according to the DDK documentation, I can't use the output buffer to transfer the filename to my private devmode structure right now, therefore leaving it to using global variables right now. Is there anything that I have overlooked (and what I've overlooked) in terms of communicating the DOCINFO structure between DrvDocumentEvent in the ui and DrvStartDoc?
  • sduffsduff Member Posts: 77
    My apologies in advance if the wording in my last email sounded too vague. Basically, I'm trying to access the devmode/extended devmode structure in DrvDocumentEvent when iEsc == DOCUMENTEVENT_STARTDOC. How would I do so by using hPrinter and hdc handles? Thanks in advance for advices.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 12 September 2022 Live, Online
Internals & Software Drivers 23 October 2022 Live, Online
Kernel Debugging 14 November 2022 Live, Online
Developing Minifilters 5 December 2022 Live, Online