diff --git a/examples/template.py b/examples/template.py index 35bb98ce..0217f110 100755 --- a/examples/template.py +++ b/examples/template.py @@ -56,12 +56,12 @@ class TemplateDevice(USBDevice): supported_languages : tuple = (LanguageIDs.ENGLISH_US,) # The revision of the device hardware. This doesn't matter to the USB specification, - # but it's sometimes read by drivers. - device_revision : int = 0 + # but it's sometimes read by drivers. 0x0001 represents "0.1" in BCD. + device_revision : int = 0x0001 # The revision of the USB specification that this device adheres to. - # Typically, you'll leave this at '2'. - usb_spec_version : int = 0x0002 + # Typically, you'll leave this at 0x0200 which represents "2.0" in BCD. + usb_spec_version : int = 0x0200 # diff --git a/facedancer/device.py b/facedancer/device.py index 1774f1f0..a8984116 100644 --- a/facedancer/device.py +++ b/facedancer/device.py @@ -77,7 +77,7 @@ class USBBaseDevice(USBDescribable, USBRequestHandler): supported_languages : tuple = (LanguageIDs.ENGLISH_US,) device_revision : int = 0 - usb_spec_version : int = 0x0002 + usb_spec_version : int = 0x0200 device_speed : DeviceSpeed = None @@ -100,14 +100,10 @@ def from_binary_descriptor(cls, data): data += b"\0" * padding_necessary # Parse the core descriptor into its components... - spec_version_msb, spec_version_lsb, device_class, device_subclass, device_protocol, \ - max_packet_size_ep0, vendor_id, product_id, device_rev_msb, device_rev_lsb, \ + spec_version, device_class, device_subclass, device_protocol, \ + max_packet_size_ep0, vendor_id, product_id, device_rev, \ manufacturer_string_index, product_string_index, \ - serial_number_string_index, num_configurations = struct.unpack_from(" bytes: """ Returns a complete descriptor for this device. """ - # FIXME: use construct, here! - d = bytearray([ 18, # length of descriptor in bytes 1, # descriptor type 1 == device - (self.usb_spec_version >> 8) & 0xff, self.usb_spec_version & 0xff, + (self.usb_spec_version >> 8) & 0xff, self.device_class, self.device_subclass, self.protocol_revision_number, @@ -684,8 +678,8 @@ def get_descriptor(self) -> bytes: (self.vendor_id >> 8) & 0xff, self.product_id & 0xff, (self.product_id >> 8) & 0xff, - (self.device_revision >> 8) & 0xff, self.device_revision & 0xff, + (self.device_revision >> 8) & 0xff, self.strings.get_index(self.manufacturer_string), self.strings.get_index(self.product_string), self.strings.get_index(self.serial_number_string),