# USBDump Conversion Interface
import itertools
import json
import subprocess
import sys
from operator import itemgetter
from pathlib import Path
from Scripts import shared
# input_path = input("File path: ")
# if input_path:
# file_path = Path("samples/" + input_path)
# else:
# file_path = Path("samples/tablet.json")
# info = json.load(file_path.open())
hub_map = {}
def get_port_type(port):
if not port["ConnectionInfoV2"]:
return shared.USBDeviceSpeeds.Unknown
supported_usb_protocols = port["ConnectionInfoV2"]["SupportedUsbProtocols"]
if supported_usb_protocols["Usb300"]:
return shared.USBDeviceSpeeds.SuperSpeed
elif supported_usb_protocols["Usb200"] and supported_usb_protocols["Usb110"]:
return shared.USBDeviceSpeeds.HighSpeed
elif supported_usb_protocols["Usb110"]:
return shared.USBDeviceSpeeds.FullSpeed
else:
return shared.USBDeviceSpeeds.Unknown
def get_device_speed(port):
speed = port["ConnectionInfo"]["Speed"]
if speed == shared.USBDeviceSpeeds.LowSpeed:
return (shared.USBDeviceSpeeds.LowSpeed, None)
elif speed == shared.USBDeviceSpeeds.FullSpeed:
speed = shared.USBDeviceSpeeds.FullSpeed
elif speed == shared.USBDeviceSpeeds.HighSpeed:
speed = shared.USBDeviceSpeeds.HighSpeed
elif speed == shared.USBDeviceSpeeds.SuperSpeed and port["ConnectionInfoV2"] and port["ConnectionInfoV2"]["Flags"]["DeviceIsOperatingAtSuperSpeedPlusOrHigher"]:
return (shared.USBDeviceSpeeds.SuperSpeedPlus, None)
elif speed == shared.USBDeviceSpeeds.SuperSpeed:
speed = shared.USBDeviceSpeeds.SuperSpeed
else:
return (shared.USBDeviceSpeeds.Unknown, speed)
if port["ConnectionInfoV2"] and port["ConnectionInfoV2"]["Flags"]["DeviceIsSuperSpeedPlusCapableOrHigher"]:
return (speed, shared.USBDeviceSpeeds.SuperSpeedPlus)
elif speed < shared.USBDeviceSpeeds.SuperSpeed and port["ConnectionInfoV2"] and port["ConnectionInfoV2"]["Flags"]["DeviceIsSuperSpeedCapableOrHigher"]:
return (speed, shared.USBDeviceSpeeds.SuperSpeed)
else:
return (speed, None)
def get_device_speed_string(port, hub_port_count=None):
speed = get_device_speed(port)
# return f"{speed[0]}{(', ' + speed[1] + ' capable') if speed[1] else ''}{(', ' + str(hub_port_count) + ' ports') if hub_port_count else ''}"
return speed[0]
def get_device_name(port):
if not port["UsbDeviceProperties"]:
port["UsbDeviceProperties"] = {}
if not port["DeviceInfoNode"]:
port["DeviceInfoNode"] = {}
if not port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]:
return port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName", "Unknown Device")
for string_desc in port["StringDescs"] or []:
if string_desc["DescriptorIndex"] == port["ConnectionInfo"]["DeviceDescriptor"]["iProduct"]:
return string_desc["StringDescriptor"][0]["bString"]
return port["UsbDeviceProperties"].get("DeviceDesc") or port["DeviceInfoNode"].get("DeviceDescName", "Unknown Device")
def get_hub_type(port):
return shared.USBDeviceSpeeds(port["HubInfoEx"]["HubType"])
# def merge_companions(controllers):
# controllers = copy.deepcopy(controllers)
# for controller in controllers:
# for port in controller["ports"]:
# if port["companion_info"]["port"]:
# companion_hub = [i for i in controllers if i["hub_name"] == port["companion_info"]["hub"]][0]
# companion_port = [i for i in companion_hub["ports"] if i["index"] == port["companion_info"]["port"]][0]
# companion_port["companion_info"]["port"] = 0
# port["companion_info"]["port"] = companion_port
# for controller in controllers:
# for port in list(controller["ports"]):
# if port["companion_info"]["port"]:
# companion_hub = [i for i in controllers if i["hub_name"] == port["companion_info"]["hub"]][0]
# companion_port = [i for i in companion_hub["ports"] if i["index"] == port["companion_info"]["port"]["index"]][0]
# companion_hub["ports"].remove(companion_port)
# return controllers
def get_hub_by_name(name):
return hub_map.get(name)
# TODO: Figure out how to deal with the hub name not matching
def get_companion_port(port):
return ([i for i in hub_map.get(port["companion_info"]["hub"], {"ports": []})["ports"] if i["index"] == port["companion_info"]["port"]] or [None])[0]
def guess_ports():
for hub in hub_map:
for port in hub_map[hub]["ports"]:
if not port["status"].endswith("DeviceConnected"):
# we don't have info. anything else is going to error
port["guessed"] = None
elif port["type_c"] or port["companion_info"]["port"] and get_companion_port(port) and get_companion_port(port).get("type_c", None):
port["guessed"] = shared.USBPhysicalPortTypes.USB3TypeC_WithSwitch
elif not port["user_connectable"]:
port["guessed"] = shared.USBPhysicalPortTypes.Internal
elif (
port["class"] == shared.USBDeviceSpeeds.SuperSpeed
and port["companion_info"]["port"]
and get_companion_port(port)
and get_companion_port(port)["class"] == shared.USBDeviceSpeeds.HighSpeed
or port["class"] == shared.USBDeviceSpeeds.HighSpeed
and port["companion_info"]["port"]
and get_companion_port(port)
and get_companion_port(port)["class"] == shared.USBDeviceSpeeds.SuperSpeed
):
port["guessed"] = shared.USBPhysicalPortTypes.USB3TypeA
elif port["class"] == shared.USBDeviceSpeeds.SuperSpeed and not port["companion_info"]["port"]:
port["guessed"] = shared.USBPhysicalPortTypes.Internal
else:
port["guessed"] = shared.USBPhysicalPortTypes.USBTypeA
def serialize_hub(hub):
hub_info = {
"hub_name": hub["HubName"],
# "class": get_hub_type(hub),
"port_count": hub["HubInfo"]["HubInformation"]["HubDescriptor"]["bNumberOfPorts"],
# "highest_port_number": hub["HubInfoEx"]["HighestPortNumber"],
"ports": [],
}
# HubPorts
hub_ports = hub["HubPorts"]
if hub_ports: # For some reason, this is sometimes null? Botched driver?
for i, port in enumerate(hub_ports):
if not port:
continue
port_info = {
"index": (port.get("PortConnectorProps") or {}).get("ConnectionIndex")
or (port.get("ConnectionInfo") or {}).get("ConnectionIndex")
or (port.get("ConnectionInfoV2") or {}).get("ConnectionIndex")
or i + 1,
"comment": None,
"class": shared.USBDeviceSpeeds.Unknown,
"status": port["ConnectionInfo"]["ConnectionStatus"],
"type": None,
"guessed": None,
"devices": [],
}
port_info["name"] = f"Port {port_info['index']}"
friendly_error = {"DeviceCausedOvercurrent": "Device connected to port pulled too much current."}
if not port_info["status"].endswith("DeviceConnected"):
# shared.debug(f"Device connected to port {port_info['index']} errored. Please unplug or connect a different device.")
port_info["devices"] = [{"error": friendly_error.get(port_info["status"], True)}]
hub_info["ports"].append(port_info)
continue
port_info["class"] = get_port_type(port)
if not port["PortConnectorProps"]:
port["PortConnectorPro
没有合适的资源?快使用搜索试试~ 我知道了~
Windows7-10-11 下 为macOS一键USB定制
共73个文件
dll:49个
pyd:13个
py:6个
需积分: 3 0 下载量 53 浏览量
2024-01-15
11:32:55
上传
评论
收藏 11.29MB ZIP 举报
温馨提示
一,使用USBToolBox定制https://github.com/USBToolBox 请下载tool和kext,推荐在win下打开定制工具,定制过程非常简单,使用USB2.0和USB3.0各一个U盘,把所有的接口都插一遍,然后导出map.kext,将该kext和之前下载的另一个kext,总共两个kext放入efi加载并重启系统。 二,使用hackintool完善 使用usbtoolbox定制后如果没有操作错误,已经可以正常使用。 使用usbtoolbox定制会有两个问题, 一是usbtoolbox不会将蓝牙,摄像头,读卡器之类的硬件设置为内建,所以需要使用hackintlool把接口类型改为internal,然后导出usbport.kext,删除usbtoolbox的两个kext,启用usbport.kext。 二是usbtoolbox可能会在oc升级后失效,所以使用hackintool导出usbport.kext是最好的方法。
资源推荐
资源详情
资源评论
收起资源包目录
Windows.zip (73个子文件)
dist
api-ms-win-core-file-l2-1-0.dll 20KB
api-ms-win-core-console-l1-1-0.dll 20KB
select.pyd 30KB
api-ms-win-core-processthreads-l1-1-1.dll 20KB
api-ms-win-core-interlocked-l1-1-0.dll 20KB
api-ms-win-core-localization-l1-2-0.dll 20KB
api-ms-win-core-processthreads-l1-1-0.dll 20KB
api-ms-win-crt-filesystem-l1-1-0.dll 20KB
python311.dll 5.49MB
api-ms-win-core-synch-l1-2-0.dll 20KB
api-ms-win-core-file-l1-1-0.dll 24KB
Windows.exe 2.05MB
VCRUNTIME140_1.dll 48KB
resources
usbdump.exe 383KB
Info.plist 847B
api-ms-win-core-heap-l1-1-0.dll 20KB
api-ms-win-crt-multibyte-l1-1-0.dll 28KB
api-ms-win-core-memory-l1-1-0.dll 20KB
_socket.pyd 78KB
api-ms-win-core-rtlsupport-l1-1-0.dll 20KB
libcrypto-1_1.dll 3.29MB
_hashlib.pyd 64KB
_ssl.pyd 157KB
_bz2.pyd 83KB
api-ms-win-core-errorhandling-l1-1-0.dll 20KB
api-ms-win-core-debug-l1-1-0.dll 20KB
api-ms-win-core-timezone-l1-1-0.dll 20KB
api-ms-win-crt-time-l1-1-0.dll 20KB
api-ms-win-core-synch-l1-1-0.dll 20KB
api-ms-win-crt-utility-l1-1-0.dll 20KB
api-ms-win-crt-process-l1-1-0.dll 20KB
Pythonwin
win32ui.pyd 1.09MB
mfc140u.dll 5.39MB
api-ms-win-core-file-l1-2-0.dll 20KB
api-ms-win-core-util-l1-1-0.dll 20KB
api-ms-win-core-fibers-l1-1-0.dll 20KB
api-ms-win-core-namedpipe-l1-1-0.dll 20KB
api-ms-win-crt-convert-l1-1-0.dll 24KB
libssl-1_1.dll 688KB
api-ms-win-crt-stdio-l1-1-0.dll 24KB
api-ms-win-core-datetime-l1-1-0.dll 20KB
api-ms-win-core-processenvironment-l1-1-0.dll 20KB
api-ms-win-crt-heap-l1-1-0.dll 20KB
_decimal.pyd 247KB
api-ms-win-crt-string-l1-1-0.dll 24KB
api-ms-win-crt-math-l1-1-0.dll 28KB
_lzma.pyd 155KB
api-ms-win-crt-environment-l1-1-0.dll 20KB
api-ms-win-core-sysinfo-l1-1-0.dll 20KB
unicodedata.pyd 1.09MB
api-ms-win-crt-runtime-l1-1-0.dll 24KB
api-ms-win-crt-locale-l1-1-0.dll 20KB
Scripts
shared.py 4KB
utils.py 7KB
__init__.py 201B
usbdump.py 12KB
_build.py 13B
iokit.py 8KB
__pycache__
__init__.cpython-311.pyc 751B
pyexpat.pyd 195KB
base_library.zip 1.67MB
ucrtbase.dll 1.07MB
api-ms-win-core-string-l1-1-0.dll 20KB
api-ms-win-crt-conio-l1-1-0.dll 20KB
api-ms-win-core-profile-l1-1-0.dll 20KB
VCRUNTIME140.dll 107KB
win32
win32api.pyd 131KB
_win32sysloader.pyd 15KB
win32trace.pyd 23KB
pywin32_system32
pywintypes311.dll 132KB
pythoncom311.dll 654KB
api-ms-win-core-handle-l1-1-0.dll 20KB
api-ms-win-core-libraryloader-l1-1-0.dll 20KB
共 73 条
- 1
资源评论
uyiwxf
- 粉丝: 10
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功