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

Endpoint/Interface specific Requests were not handled by correct handler function #44

Closed
wants to merge 3 commits into from

Conversation

mrh1997
Copy link
Contributor

@mrh1997 mrh1997 commented Jul 30, 2020

Requests that are Endpoint/Interface specific did not call the handler method within the corresponding USBEndpoint/USBInterface object. Usually these handler methods are decorated by @to_this_endpoint or @to_this_interface. But both decorators did not work as expected:

  • to_this_endpoint worked only on IN endpoint with address 15
  • to_this_interface delegated all requests to the first interface implementing the corresponding descriptor.
    This is for example problematic when implementing a composite usb device consisting of i.e. two independent HID devices (both providing a REPORT descriptor). The GetDescriptor command for retrieving the REPORT descriptor will always return the REPORT descriptor of the first interface (no matter what index parameter is passed).

mrh1997 added 3 commits July 30, 2020 12:22
The to_this_endpoint() decorator based on the _wrap_with_field_matcher() helper did not compare the
requests index against the endpoints address but against the static value 0b10001111.
…multiple interfaces

The to_this_interface() decorator based on the _wrap_with_field_matcher() did
not check the "index" field of the request. Thus always the first interfaces
request handler was run.
USBDevice.handle_generic_get_descriptor_request() is called from
USBInterface and USBDevice. Both callers passed themself as "self",
which is technicially not correct, as "self" always has to be
of type USBDevice.

Now the signature is changed, so that it shows all
possible types correctly.
@antoinevg
Copy link
Member

Great catch, thank you for the PR!

Merged in facedancer-v3 branch: antoinevg#1

@antoinevg antoinevg closed this Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement potential new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants