Solved

OSR USB Fx-2

Posted on 2006-07-11
18
986 Views
Last Modified: 2008-02-20
Hi ,

   When i run the bugger for OSR USB fx-2, I cannot know the current line in source code when i use p command. However, i can see the current line in disambly file.
   I want to run debugger in the way as i did in visual c++ => so i can understant the sample driver of USB fx-2 .Please help me.
0
Comment
Question by:valleytech
  • 8
  • 5
  • 3
18 Comments
 
LVL 30

Expert Comment

by:Axter
Comment Utility
Hi valleytech,
Make sure the debugger sympath is pointing to the path that contains your *.pdb file.
Make sure the debuger image path is pointing to your binary executable.
And make sure the source path is pointing to your source code.


David Maisonave (Axter)
Cheers!
0
 
LVL 30

Expert Comment

by:Axter
Comment Utility
You can also try the following command:
!analyze -v

If that still doesn't work, try reloading the binary by use .reload command.
Example:
.reload /i /f gxhsm.sys
0
 

Author Comment

by:valleytech
Comment Utility
oh Axter,

 Let's me tell you my scenario case. I downloaded 2 files from osronline. After extract the zip files, i installed successfully the driver in my target system. I verify my claim by going to Hardware-> Device Manager...

  In the host system, i also have 2 folders WDF_Usb_driver and usbfx2lk_v1.2 inside C:\drivers_compiled.  After i use build command inside WDF_Usb_driver, i have wdf_usb.sys inside the i386 folder. In that folder i also have wdf_usb.pdb. So this is the path debugger symbol path point to. (Make sure the debugger sympath is pointing to the path that contains your *.pdb file.)

  I don't know where is the binary executable file so my debugger image path can point to. I didn't use Visual C++ compile so how i can have the executable file.

  I am not sure about the source code. is that the file which has DriverEntry?? If so , i need to point usbfx2lk.cpp inside C:\drivers_compiled\usbfx2lk_v1.2\src\driver. Am i right?

  Thanks for you help + patience.

 
   
0
 
LVL 30

Accepted Solution

by:
Axter earned 250 total points
Comment Utility
>> I don't know where is the binary executable file so my debugger image path can point to
The executable is the wdf_usb.sys file.

>>I am not sure about the source code. is that the file which has DriverEntry??
Yes.

>>If so , i need to point usbfx2lk.cpp inside C:\drivers_compiled\usbfx2lk_v1.2\src\driver. Am i right
No, you need to point Windbg to the location of usbfx2lk.cpp
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 250 total points
Comment Utility
Did you build this driver or you use .sys file downloaded from OSR?
For debugging you need to build file in checked configuration, copy resulting .sys file to target computer and execute it.
Use KMDF OSR sample driver which is supplied with Microsoft WDF. You can find it in WINDDK\WDF\KMDF10\src\kmdf\osrusbfx2 directory. osrusbfx2.htm file contains driver description, building and installation notes. Don't use driver downloaded from OSR, this is old WDM driver.

I wrote batch file which builds this driver, this file sets required configuration environment and runs DDK build utility:

call C:\WINDDK\3790~1.183\bin\setenv.bat C:\WINDDK\3790~1.183 chk WXP
C:
cd \
cd WINDDK\WDF\KMDF10\src\kmdf\osrusbfx2
set WDF_ROOT=C:\WINDDK\WDF\KMDF10\
build -ceZ
pause

Place this file to C:\WINDDK\WDF\KMDF10\src\kmdf\osrusbfx2 directory and run it. First line sets DDK checked build environment. Line #5 sets environment variable required for WDF build.
You can create Visual Studio makefile project, add driver source files to it, and run this batch file as build command.
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
When driver is built (hopefully), you will find the following files in the objchk_wxp_x86\i386 subdirectory:
osrusbfx2.sys - driver executable
osrusbfx2.inf - inf file which is used for driver installation. It is created from .inx file in source directory.

Copy both files on the target computer, connect OSR devise and select osrusbfx2.inf file in New Hardware Wizard. This will install the driver on target computer. Copy also testing executable to target computer and run it.

Notice that .inf file contains the following lines:

[CoInstaller_CopyFiles]
WdfCoinstaller01000.dll

WdfCoinstaller01000.dll is Dll which is used to install KMDF files. It should be placed on target computer in the same directory as .inf and .sys files, to be available for installation. You can find this Dll somewhere in WINDDK\WDF directory.
0
 

Author Comment

by:valleytech
Comment Utility
wow. I could install the driver in by using my own built .sys file. I mean I "build" it agin.  Let's me follow your guide.
PS:  I also modify the .inf file for wdfcoinstaller01001.dll and copy from KMDF10\redist\wdf\x86free
0
 

Author Comment

by:valleytech
Comment Utility
here is my step by step to do debugger
  Let's tell tell all of my steps.
  1. create a folder c:\a on host system
  2. dl usbfx2lk_v1.2.zip example driver at
     http://www.osronline.com/article.cfm?article=371
     and save to c:\a
  3. unzip usbfx2lk_v1.2.zip to usbfx2lk_v1.2 folder
  4. open the Windows Xp Checked Build Enviroment and go to
      C:\WinDDK\WDF\KMDF10
  5. execute " set_wdf_env" command
  6. On the same Windows Xp checked build enviroment, go to
      C:\a\usbfx2lk_v1.2\src\driver
  7. execute "build" command
  8. Browser to C:\a\usbfx2lk_v1.2\src\driver to copy file
        usbfx2lk setup information
     and Browser to C:\a\usbfx2lk_v1.2\src\driver\objchk_wxp_x86\i386
        to copy file usbfx2lk system file
  9. create a folder c:\a on target system
     and paste 2 files in step 8 in it. I can install the driver when New hardware found and point to c:\a for usbfx2lk.sys file.... I verify it by Device Manager-> hardware list. It works.
  10.in debugger, point symbol file path to
srv*e:\symbols\websymbols*http://msdl.microsoft.com/download/symbols;
;C:\a\usbfx2lk_v1.2\src\driver\objchk_wxp_x86\i386
  11. in debugger, point source file path to
C:\a\usbfx2lk_v1.2\src\driver
  12. in debugger, point image file path to
 C:\a\usbfx2lk_v1.2\src\driver\objchk_wxp_x86
  13. setup connection between host and target system...
  14. in debugger, File-> Open Source file browser for
       usbfx2lk.cpp
 
   The windbg debugger can run , but i can't see the current line on the source file which is usbfx2lk.cpp. So I can't follow the debugger because it only show me the asembly line.

   Could you please follow the same procedure above and correct for me? Thanks alot.

PS: this is the most challenge technique i've faced.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Again, this is WDM driver, and not KMDF. Do you really need it or you want to work with Microsoft KMDF driver sample?
I didn't work with OSR driver. I know that Microsoft KMDF driver for OSR device has testing application which runs the driver. To start debugging you need to run driver by some way, and this is done using testing application. I don't know specific details about OSR WDM driver.
Refer to my first post about Microsoft driver sample.
0
 

Author Comment

by:valleytech
Comment Utility
Oh I want to learn KMDF because it's easier to follow. My target is to trace the source code of USBFx2 device driver. I bought the device already. I don't know how to start. I am very confused about it. Thanks.
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Start with Microsoft KMDF OSR driver. This is actually tutorial which contains number of steps, with build and installation instruction and client user-mode application.
On the first step, build driver and client, install driver and run client application. Then add some debug output to driver using KdPrint and see result with DbgView program from www.sysinternals.com. After these simple steps, when you know how to build, install and run driver, try to debug it.
0
 

Author Comment

by:valleytech
Comment Utility
hi alex,
 
 On the article " An introduction to how to build, install, test, and debug KMDF drivers" by Microsoft,  at page 21 ( you use print review to get that page) they post How to Use Windbg with Featured Toaster.
 
 Could you please spend a little bit time to follow that guide? I get lost to it. Hope you can post the step-by-step guide by your own. Thanks a lot for your understanding.
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
There is no difference in debugging KMDF drivers and old drivers. I use instruction which is posted in one of your previous questions, it works also for KMDF drivers.
0
 

Author Comment

by:valleytech
Comment Utility
I used your instruction. It works for the "hello driver". however, it can't show me the current line in source code when I run debugger for the USB FX2 driver. It only shows me the current line in assembly language. Please show me what i did wrong. Thanks.
0
 

Author Comment

by:valleytech
Comment Utility
I've installed the driver of usbfx2 to the target system.
 I just wonder when i run debugger for usbfx2, do i need to unplug the device or just leave it there? Thanks.
0
 

Author Comment

by:valleytech
Comment Utility

 Before when i ran debugger for "hello driver", i can use the OSRLoader to start and stop service-> debug successfully.
 Now  when i set the breakpoint in usbfx2lk.cpp at the DriverEntry, windbg pop up a message " debuggee must be stopped before breakpoints can be modified". I don't know how i can stop debuggee for usbfx2 driver?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now