Thanks Stephan,
I've debugged it using latest LIBUSB source code. It is actually failing in DeviceIoControl function which is returning error code 998 means ERROR_NOACCESS. Below are my findings:
usb_control_msg calls _usb_io_sync with following parameters
dev->impl_info : 0x00000df4 // this is fine
code: 0x00222034 // It also looks fine
out: 0x041efd4c
out_size: 0x00000018
in : 0x034efd00
in_size: 0x000003fc
read: 0x00000000
This _usb_io_sync then calls DeviceIoControl with following parameters:
dev: 0x00000df4
code: 0x00222034
out: 0x041efd4c
out_size: 0x00000018
in: 0x034efd00
in_size: 0x000003fc
NULL,
ol: every thing is NULL in it.......looks fine
it fails and GetLastError returns 998............any idea Y is it failing........one thing very interesting is that what we are passing in out parameter is actually in parameter for DeviceIoControl.......you can see it
here ...........you can see 3rd and 4th parameters
> Date: Mon, 5 May 2008 08:27:34 +0200
> From: ste.meyer1 <at> googlemail.com
> To: libusb-win32-devel <at> lists.sourceforge.net
> Subject: Re: [Libusb-win32-devel] Problem with DeviceIoControl
>
> These constants are defined in the Makefile. Just pass these constants
> as command line arguments to your compiler if you're not using GCC.
>
> Stephan
>
>
> On 5/5/08, Taimoor Mirza <mooni_mirza <at> hotmail.com> wrote:
> > Stephen,
> >
> > I tried to compile this windows.c with other files of libusb and I am
> > getting following errors:
> >
> > 1>Compiling...
> > 1>windows.c
> > 1>.\windows.c(56) : error C2065: 'VERSION_MAJOR' : undeclared identifier
> > 1>.\windows.c(56) : error C2099: initializer is not a constant
> > 1>.\windows.c(57) : error C2065: 'VERSION_MINOR' : undeclared identifier
> > 1>.\windows.c(57) : error C2099: initializer is not a constant
> > 1>.\windows.c(58) : error C2065: 'VERSION_MICRO' : undeclared identifier
> > 1>.\windows.c(58) : error C2099: initializer is not a constant
> > 1>.\windows.c(59) : error C2065: 'VERSION_NANO' : undeclared identifier
> > 1>.\windows.c(59) : error C2099: initializer is not a constant
> > 1>.\windows.c(64) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(64) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(64) : error C2059: syntax error : 'type'
> > 1>.\windows.c(66) : error C2059: syntax error : ')'
> > 1>.\windows.c(67) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(67) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(67) : error C2059: syntax error : 'type'
> > 1>.\windows.c(69) : error C2059: syntax error : ')'
> > 1>.\windows.c(73) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(73) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(73) : error C2059: syntax error : 'type'
> > 1>.\windows.c(73) : error C2059: syntax error : ')'
> > 1>.\windows.c(121) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(121) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(121) : error C2059: syntax error : ')'
> > 1>.\windows.c(122) : error C2054: expected '(' to follow 'dev'
> > 1>.\windows.c(184) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(184) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(184) : error C2059: syntax error : ')'
> > 1>.\windows.c(185) : error C2054: expected '(' to follow 'dev'
> > 1>.\windows.c(202) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(202) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(202) : error C2059: syntax error : 'type'
> > 1>.\windows.c(202) : error C2059: syntax error : ')'
> > 1>.\windows.c(242) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(242) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(242) : error C2059: syntax error : 'type'
> > 1>.\windows.c(242) : error C2059: syntax error : ')'
> > 1>.\windows.c(281) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(281) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(281) : error C2059: syntax error : 'type'
> > 1>.\windows.c(281) : error C2059: syntax error : ')'
> > 1>.\windows.c(316) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(316) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(316) : error C2059: syntax error : 'type'
> > 1>.\windows.c(316) : error C2059: syntax error : ')'
> > 1>.\windows.c(359) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(359) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(359) : error C2059: syntax error : 'type'
> > 1>.\windows.c(361) : error C2059: syntax error : ')'
> > 1>.\windows.c(483) : error C2065: 'ETIMEDOUT' : undeclared identifier
> > 1>.\windows.c(550) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(550) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(550) : error C2059: syntax error : 'type'
> > 1>.\windows.c(552) : error C2059: syntax error : ')'
> > 1>.\windows.c(596) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(596) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(596) : error C2059: syntax error : 'type'
> > 1>.\windows.c(597) : error C2059: syntax error : ')'
> > 1>.\windows.c(603) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(603) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(603) : error C2059: syntax error : 'type'
> > 1>.\windows.c(604) : error C2059: syntax error : ')'
> > 1>.\windows.c(610) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(610) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(610) : error C2059: syntax error : 'type'
> > 1>.\windows.c(611) : error C2059: syntax error : ')'
> > 1>.\windows.c(617) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(617) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(617) : error C2059: syntax error : 'type'
> > 1>.\windows.c(618) : error C2059: syntax error : ')'
> > 1>.\windows.c(624) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(624) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(624) : error C2059: syntax error : 'type'
> > 1>.\windows.c(625) : error C2059: syntax error : ')'
> > 1>.\windows.c(635) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(635) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(635) : error C2059: syntax error : 'type'
> > 1>.\windows.c(635) : error C2059: syntax error : ')'
> > 1>.\windows.c(645) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(645) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(645) : error C2059: syntax error : 'type'
> > 1>.\windows.c(646) : error C2059: syntax error : ')'
> > 1>.\windows.c(656) : error C2143: syntax error : missing ')' before '*'
> > 1>.\windows.c(656) : error C2143: syntax error : missing '{' before '*'
> > 1>.\windows.c(656) : error C2059: syntax error : 'type'
> > 1>.\windows.c(657) : error C2059: syntax error : ')'
> >
> > Where is this VERSION_MAJOR and other macros are declared? Any idea?
> >
> > -Taimoor
> >
> >
> > > Date: Wed, 30 Apr 2008 08:42:21 +0200
> >
> > > From: ste.meyer1 <at> googlemail.com
> > > To: libusb-win32-devel <at> lists.sourceforge.net
> > > Subject: Re: [Libusb-win32-devel] Problem with DeviceIoControl
> > >
> > > Please try the latest windows.c from the SVN
> > >
> > (http://libusb-win32.svn.sourceforge.net/viewvc/libusb-win32/trunk/libusb/src/)
> > >
> > > There had been some changes since the last release.
> > >
> > > Stephan
> > >
> > >
> > >
> > > On 4/30/08, Taimoor Mirza <mooni_mirza <at> hotmail.com> wrote:
> > > > Well actually the problem that I am getting is the one I mentioned in
> > last
> > > > paragraph of my email i.e. I am actually trying to communicate with a
> > > > printer device using libusb.lib and driver dll. I installed driver
> > > > successfully and my testlibusb-win.exe is running fine.
> > > >
> > > > But the problem is that in my application when call usb_control_msg to
> > send
> > > > class specific request to get device ID of my printer device it returns
> > -5.
> > > >
> > > > Parameters I am passing to this call are
> > > > bmRequestType = 0xa1
> > > > bRequest = 0x00 // Class specific request to get device Id
> > > >
> > > > Now I don't know why is it happening.I've used usb analyzer to check
> > whether
> > > > printer device is rejecting this request or something else. What I've
> > found
> > > > out is that usb_control_msg does not send this request to usb bus.
> > > >
> > > > I then thought to debug it myself........for that I took the source code
> > of
> > > > libusb and built my own library and dll....just to debug. But doing so I
> > > > found out that I am getting error in DeviceIoControl method in
> > > > usb_os_find_devices of windows.c.
> > > >
> > > > I hope you've got my point..........
> > > >
> > > > > Date: Tue, 29 Apr 2008 15:05:30 +0200
> > > > > From: ste.meyer1 <at> googlemail.com
> > > > > To: libusb-win32-devel <at> lists.sourceforge.net
> > > > > Subject: Re: [Libusb-win32-devel] Problem with DeviceIoControl
> > > >
> > > > >
> > > > > What is LIBUSB_IOCTL_GET_DEVICE_INFO?
> > > > > Why aren't you using the DLL that comes with the driver?
> > > > >
> > > > >
> > > > > On 4/29/08, Taimoor Mirza <mooni_mirza <at> hotmail.com> wrote:
> > > > > > Hi all,
> > > > > >
> > > > > > I am trying to run my application for printer device. I've installed
> > > > device
> > > > > > driver for this device but I am getting a problem in my
> > > > usb_os_find_devices
> > > > > > method in windows.c . In this method my CreateFile runs successfully
> > and
> > > > > > returned me handle of device.
> > > > > >
> > > > > > But after that when DeviceIoControl method is called it fails. I've
> > > > checked
> > > > > > the error message using GetLastError and it is returning 87 means
> > > > > > INVALID_PARAMETER. Below is code of usb_os_find_devices method
> > > > > >
> > > > > >
> > > > > >
> > > > > > handle = CreateFile(dev->filename, 0, 0, NULL, OPEN_EXISTING,
> > > > > > FILE_ATTRIBUTE_NORMAL, NULL);
> > > > > >
> > > > > > if(handle == INVALID_HANDLE_VALUE)
> > > > > > {
> > > > > > free(dev);
> > > > > > stat = GetLastError();
> > > > > > continue;
> > > > > > }
> > > > > >
> > > > > > if(!DeviceIoControl(handle, LIBUSB_IOCTL_GET_DEVICE_INFO,
> > > > > > &req, sizeof(libusb_request),
> > > > > > &req, sizeof(libusb_request),
> > > > > > &ret, NULL))
> > > > > > {
> > > > > > USB_MESSAGE_STR(LIBUSB_DEBUG_ERR,
> > "usb_os_find_devices:
> > > > > > getting "
> > > > > > "device info failed");
> > > > > > CloseHandle(handle);
> > > > > > stat = GetLastError();
> > > > > >
> > > > > > ...................
> > > > > >
> > > > > > Any clue? One more thing is that if I use libusb library then it
> > does
> > > > not
> > > > > > give this problem. But in that case when I call usb_control_msg to
> > send
> > > > > > class specific request to get device ID of my printer device it
> > returns
> > > > -5.
> > > > > > Parameters I am passing to this call are
> > > > > > bmRequestType = 0xa1
> > > > > > bRequest = 0x00 // Class specific request to get device Id
> > > > > >
> > > > > > -mooni
> > > > > >
> > > > > >
> > > > > >
> > > > > > ________________________________
> > > > > > Discover the new Windows Vista Learn more!
> > > > > >
> > > >
> > -------------------------------------------------------------------------
> > > > > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > > > > > Don't miss this year's exciting event. There's still time to save
> > $100.
> > > > > > Use priority code J8TL2D2.
> > > > > >
> > > >
> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> > > > > > _______________________________________________
> > > > > > Libusb-win32-devel mailing list
> > > > > > Libusb-win32-devel <at> lists.sourceforge.net
> > > > > >
> > > >
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > -------------------------------------------------------------------------
> > > > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > > > > Don't miss this year's exciting event. There's still time to save
> > $100.
> > > > > Use priority code J8TL2D2.
> > > > >
> > > >
> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> > > > > _______________________________________________
> > > > > Libusb-win32-devel mailing list
> > > > > Libusb-win32-devel <at> lists.sourceforge.net
> > > > >
> > > >
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> > > >
> > > >
> > > > ________________________________
> > > > Get news, entertainment and everything you care about at Live.com. Check
> > it
> > > > out!
> > > >
> > -------------------------------------------------------------------------
> > > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > > > Don't miss this year's exciting event. There's still time to save $100.
> > > > Use priority code J8TL2D2.
> > > >
> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> > > > _______________________________________________
> > > > Libusb-win32-devel mailing list
> > > > Libusb-win32-devel <at> lists.sourceforge.net
> > > >
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> > > >
> > > >
> > >
> > >
> > -------------------------------------------------------------------------
> > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > > Don't miss this year's exciting event. There's still time to save $100.
> > > Use priority code J8TL2D2.
> > >
> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> > > _______________________________________________
> > > Libusb-win32-devel mailing list
> > > Libusb-win32-devel <at> lists.sourceforge.net
> > >
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> >
> >
> > ________________________________
> > Invite your mail contacts to join your friends list with Windows Live
> > Spaces. It's easy! Try it!
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > Don't miss this year's exciting event. There's still time to save $100.
> > Use priority code J8TL2D2.
> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> > _______________________________________________
> > Libusb-win32-devel mailing list
> > Libusb-win32-devel <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> >
> >
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Libusb-win32-devel mailing list
> Libusb-win32-devel <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Get news, entertainment and everything you care about at Live.com.
Check it out!