02-uunicorn-sandbox-argv-dispatch.md 2.3 KB

Draft: uunicorn/synaWudfBioUsb-sandbox — argv dispatch + match exit status

Where: https://github.com/uunicorn/synaWudfBioUsb-sandbox Type: PR Attach: work/patches/uunicorn-sandbox-argv-dispatch.patch (applies to hello.cc HEAD)


Title

Enable the documented nop|identify|enroll dispatch and return a match exit status

Body

Two small improvements to hello.cc:

1. The README documents ./run.sh [ nop | identify | enroll ], but the dispatch in main() is #if 0'd and the flow is hardcoded to enroll() + identify(). As a result nop and identify currently perform a full re-enrollment (10 finger captures) before identifying. The patch enables the existing dispatch so:

  • identify → setMode(2) + identify() only — a true verify-only run
  • enroll → enroll() + (existing 10s pause) + identify(), as before
  • nop → nothing extra
  • any other/no argument → usage + exit 3

2. Return a match status. identify() / identifyFeatureSet() now return an int and main() exits 0 when the sensor returns an identify record and 1 on no-match, so the binary can be used from scripts/PAM wrappers.

How match/no-match look (verified against a real 06cb:0081 via the 0x442004 IdentifyFeatureSet ioctl):

  • match: the stored record comes back with a non-zero type/size header (e.g. starts 03 00 00 00 1c 00 00 00 …)
  • no match: the structure is zeroed (only a WinBio error dword further in), i.e. first bytes are 00 00 00 00 …

The patch detects a record via a non-zero header (first 8 bytes) rather than any payload-specific match, so it works for any enrolled identity.

Testing caveat: I could not compile it here (the project needs the WDK winbio_*.h / WDF headers as per the README). I validated the behavior by binary-patching the prebuilt a.exe instead (NOP out call enroll, Sleep(10000) → Sleep(0)) and running verify-only against real hardware — that flow works. The source patch is mechanical, but please compile-test before merging.

Why it matters: verify-only runs are what you want for authentication use-cases (e.g. a PAM module for sudo/login) — re-enrolling on every check makes the "identify" mode unusable for that. With this patch, a.exe identify is directly scriptable.