Search This Blog

Saturday, November 10, 2012

Toaster device - installing wdm driver

I have been trying to understand how toaster wdm device works and apparently I spent so much time trying to install these drivers on my VM. First of all, its readme file is helpful but I found it lacking in some of its explanations. At first, I used devcon.exe to install bus driver but I bumped into a couple of issues so I could not install bus driver properly.
I searched online and found this msdn page where on the bottom it explains how to install toaster bus driver.

So that was helpful and on to the next issue: function driver. I could start up toaster by using enum.exe but it could not find some files that function driver was not installed. The message was not really helpful in that it does not say which files missing and part of it is that I do not fully understand what's needed for this install to happen. I could have spent time understanding installing package requirement but my goal was to understand Power management using this toaster before anything else.
Then, again from online I learned that I can look at setupapi.dev.log for more clue. By the way, this file is located in C:\Windows\inf directory.
Here is the error message I found from log file:
!!!  flq:                               Error installing file (0x00000002)
!!!  flq:                               Error 2: The system cannot find the file specified.
!    flq:                                    SourceFile   - 'c:\work\toaster\device\amd64\tostrco2.dll'
!    flq:                                    TargetFile   - 'C:\Users\ILHOYE~1.RED\AppData\Local\Temp\{6d5b7b46-959d-0823-c45e-094dc5a9816c}\amd64\tostrco2.dll'


By now, it is clear that I am missing tostrco2.dll. I don't know what file is for but I know that I need it. So I grabbed this from WDK and after that I could install toaster function driver. Now, I can happily debug toaster to understand the code flow.

How about traces? Is there any traces available with toaster driver? Yes, many of kernel drivers use either ETW or WPP tracing and hence by providing appropriate information you can turn on/off debug messages. These messages can be captured and saved to the file or you can actually see them if you have the debugger attached to your target machine/VM. In fact, toaster driver readme file describes the steps to do it but let me repeat that here. First of all, start the trace session by executing the following command where toaster.ctl contains "C56386BD-7C67-4264-B8D9-C4A53B93CBEB toaster"

c:\temp>tracelog -start toaster -rt -kd -ft 1 -guid toaster.ctl -flags 0xff

After that, in the kernel debugger you need to set the wmi path to refer to the TMF file location. What's TMF file? It is the file that contains information to translate the debug message to human readable strings. You can generate tmf file from pdb file by running 'tracepdb -f toaster.pdb' Here is how to set the path and enable debugging message.

kd>!wmitrace.searchpath + path_of_TMF_files
kd> !wmitrace.strdump
(WmiTracing)StrDump Generic
  LoggerContext Array @ 0x80BF1760 [64 Elements]
    Logger Id  2 @ 0x820C5000 Named 'MSDTC_TRACE_SESSION'
    Logger Id  3 @ 0x81AAF000 Named 'toaster'

kd> !wmitrace.enable 3
With that, you should be able to see the trace messages. Of course, you can always set the breakpoint where you are interested in to look into more details but knowing how to leverage existing traces should be helpful.

For toaster bus driver, if you want to see the debug messages, you will need to use chk build and use dbgview to enable kernel verbose debugging. However, once you turn on kernel verbose debugging, it will generate all sorts of debugging messages that you may not care about. Toaster bus driver uses DbgPrint for debug messages and that is essentially same as the following.

DbgPrintEx ( DPFLTR_DEFAULT_ID, DPFLTR_INFO_LEVEL, Format, arguments )

Therefore, we need to enable mask and level according to our mask and level. We can do this either updating registry or updating values via kernel debugger. For more information, please refer to MSDN page 'Reading and Filtering Debugging Messages' that describes how to enable certain component.


13 comments:

  1. are composed of gray-white. Panel command
    is the basis of a curriculum vitae, listing, take out, treatment of paper jam button
    and a number of other indications on the within. This
    HP LaserJet printer is not as.

    Here is my website :: s-hue.co.kr

    ReplyDelete
  2. hey, plz support me, my printer cd r missplaced so i cani reinsstal
    vehicle drivers, plz provide me the online setup.


    Also visit my weblog ... xerox phaser 8560 drivers

    ReplyDelete
  3. Your blog post, Teknogeekz; High Technology Solutions,
    Puerto Vallarta and the globe & raquo; Blog Archive & raquo; Xerox Phaser 6125N Cross System Shade Laser Printer, is actually well
    written and informative. Glad I found your web site, warm regards!


    Visit my web blog: Xerox phaser 8560 error codes

    ReplyDelete
  4. Very good information. Lucky me I found your site by chance (stumbleupon).

    I have bookmarked it for later!

    My web blog :: xerox 8560dn

    ReplyDelete
  5. Hi, yup this piece of writing is actually fastidious and I have learned lot
    of things from it regarding blogging. thanks.

    My web blog; statement jewellery uk

    ReplyDelete
  6. you are so warm.

    Here is my site - galilee.ezpt.kr

    ReplyDelete
  7. I enjoy Rashida's earrings since she was selling them with a sheet of foam core in the streets of Center City during our days at the Art Institute. I'm
    glad all of you ar giving her some exposure. Go Shida!



    my blog ... ,Jewellery discount codes

    ReplyDelete
  8. I have a grinding noise that is keeping me from
    printing everything from the Cyan toner. Could
    this be the same instance?

    Also visit my blog :: xerox phaser 8560mfp

    ReplyDelete
  9. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.

    You definitely know what youre talking about,
    why throw away your intelligence on just posting videos to your site when you could
    be giving us something informative to read?

    Feel free to surf to my blog UK hosting :: ukbesthosting.info ::

    ReplyDelete
  10. up until which time i m able to get this motorist.

    Also visit my weblog ... xerox phaser 8560 maintenance kit (esdesire.net)

    ReplyDelete
  11. Many thanks for this solution!

    Also visit my web site; xerox phaser 8560 manual

    ReplyDelete
  12. Sir, pls send out that video to my email I.D. It will certainly
    be assistance ful 2 make pcb effortless. Thankyou.

    Also visit my page ... xerox phaser 8560 error codes (www.didactica.umich.mx)

    ReplyDelete