mirror of
https://github.com/hyugogirubato/KeyDive.git
synced 2024-12-22 19:13:35 +00:00
Improve library vendor detection
This commit is contained in:
parent
405c184558
commit
4bcabf1101
@ -107,6 +107,17 @@ def main() -> None:
|
|||||||
# Initialize Core instance for interacting with the device
|
# Initialize Core instance for interacting with the device
|
||||||
core = Core(cdm=cdm, device=args.device, functions=args.functions)
|
core = Core(cdm=cdm, device=args.device, functions=args.functions)
|
||||||
|
|
||||||
|
# Map process keys to their compatible CDM vendors
|
||||||
|
cdm_vendor = {}
|
||||||
|
for key, vendors in CDM_VENDOR_API.items():
|
||||||
|
for vendor in vendors:
|
||||||
|
# Check if vendor's SDK matches the core's SDK or the previous version
|
||||||
|
if vendor.sdk in (core.sdk_api, core.sdk_api - 1):
|
||||||
|
cdm_vendor.setdefault(key, []).append(vendor)
|
||||||
|
|
||||||
|
if not cdm_vendor:
|
||||||
|
raise NotImplementedError('SDK version is not supported.')
|
||||||
|
|
||||||
# Process watcher loop
|
# Process watcher loop
|
||||||
logger.info('Watcher delay: %ss' % args.delay)
|
logger.info('Watcher delay: %ss' % args.delay)
|
||||||
current = None
|
current = None
|
||||||
@ -115,7 +126,7 @@ def main() -> None:
|
|||||||
processes = {
|
processes = {
|
||||||
key: (name, pid)
|
key: (name, pid)
|
||||||
for name, pid in core.enumerate_processes().items()
|
for name, pid in core.enumerate_processes().items()
|
||||||
for key in CDM_VENDOR_API.keys() if key in name
|
for key in cdm_vendor.keys() if key in name
|
||||||
}
|
}
|
||||||
|
|
||||||
if not processes:
|
if not processes:
|
||||||
@ -136,7 +147,7 @@ def main() -> None:
|
|||||||
for key, (name, pid) in processes.items():
|
for key, (name, pid) in processes.items():
|
||||||
if current:
|
if current:
|
||||||
break
|
break
|
||||||
for vendor in CDM_VENDOR_API[key]:
|
for vendor in cdm_vendor[key]:
|
||||||
if core.hook_process(pid=pid, vendor=vendor):
|
if core.hook_process(pid=pid, vendor=vendor):
|
||||||
logger.info('Process: %s (%s)', pid, name)
|
logger.info('Process: %s (%s)', pid, name)
|
||||||
current = pid
|
current = pid
|
||||||
|
Loading…
Reference in New Issue
Block a user