OSR USB Fx-2

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.
valleytechAsked:
Who is Participating?
 
AxterConnect With a Mentor Commented:
>> 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
 
AxterCommented:
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
 
AxterCommented:
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
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

 
valleytechAuthor Commented:
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
 
AlexFMConnect With a Mentor Commented:
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
 
AlexFMCommented:
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
 
valleytechAuthor Commented:
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
 
valleytechAuthor Commented:
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
 
AlexFMCommented:
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
 
valleytechAuthor Commented:
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
 
AlexFMCommented:
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
 
valleytechAuthor Commented:
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
 
AlexFMCommented:
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
 
valleytechAuthor Commented:
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
 
valleytechAuthor Commented:
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
 
valleytechAuthor Commented:

 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
All Courses

From novice to tech pro — start learning today.