Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win access violation on sending a report #11

Closed
dccharacter opened this issue Feb 15, 2014 · 2 comments
Closed

Win access violation on sending a report #11

dccharacter opened this issue Feb 15, 2014 · 2 comments

Comments

@dccharacter
Copy link

I'm trying to send a report (through either assigning a value to usage or through setting raw data). And get violation:
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Python27\lib\lib-tk\Tkinter.py", line 1470, in call
return self.func(*args)
File "D:\Development\Python\USB_HID_Client\HID_Client.py", line 98, in led3
r.send()
File "D:\Python27\lib\site-packages\pywinusb\hid\core.py", line 1463, in send
self.__prepare_raw_data()
File "D:\Python27\lib\site-packages\pywinusb\hid\core.py", line 1418, in __prepare_raw_data
byref(self.__raw_data), self.__raw_report_size) )
WindowsError: exception: access violation reading 0xFFFFFFFF002EC590

This is the call for hid_dll.HidP_SetData():
if n_total_usages:
#some usages set
usage_len = c_ulong(n_total_usages)
HidStatus( hid_dll.HidP_SetData(self.__report_kind,
byref(data_list), byref(usage_len),
self.__hid_object.ptr_preparsed_data,
byref(self.__raw_data), self.__raw_report_size) )

I don't think I'm doing something wrong.... It's either Win 7 x64 problem or a bug.

Also, assigning values by usage is a pain. How am I supposed to know page_id and usage_id?
E.g. I have usage page "Vendor define 1". I just spent an hour reverse-finding it from finding all usages and then get_short_usage_id and get_usage_page_id. It was painful...

@rene-aguirre
Copy link
Owner

I just uploaded a couple of examples for setting data. One of them does it by both using usages and a redundant raw data setting. Both tested working with Windows 7 64 bits, using Python 64 bits also.

Raw data setting has the disadvantage that you need to know the report binary format, so you are right, you need to know your usage, how? there are some already standardized (http://www.usb.org/developers/devclass_docs/Hut1_11.pdf), if you actually see vendor pages (values starting at 0xff00) you'd need to have some vendor specific documentation (maybe you could ask for technical support).

Otherwise, use the show_hids.py example and capture the output to a text file, use your prefered editor to find out what capabilities are available in your system, browse to your target device for some hints.

If you are reverse engineering a device, use a USB sniffer (like in a filter driver) that captures the transactions to a file, then once identified the HID reports, use a script to set the raw data and know what are the HID usages affected.

For business you might want to buy a commercial USB protocol analyzer (software or hardware).

Anyway, please try the new examples and let me know if they break on your machine, it would be good to try them on other machine, or better, share your script and some data :-)

@dccharacter
Copy link
Author

Thanks a lot Rene!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants