diff --git a/SoftU2FDriver/SoftU2FDriver.cpp b/SoftU2FDriver/SoftU2FDriver.cpp index 01761c8..dcc4b15 100644 --- a/SoftU2FDriver/SoftU2FDriver.cpp +++ b/SoftU2FDriver/SoftU2FDriver.cpp @@ -35,3 +35,15 @@ void SoftU2FDriver::free() { IOWorkLoop* SoftU2FDriver::getWorkLoop() const { return _workLoop; } + +IOReturn SoftU2FDriver::newUserClient(task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) { + IOLog("%s[%p]::%s()\n", getName(), this, __FUNCTION__); + + // Check that another client isn't already connected. + if (getClient()) { + IOLog("%s[%p]::%s() -> kIOReturnExclusiveAccess\n", getName(), this, __FUNCTION__); + return kIOReturnExclusiveAccess; + } + + return super::newUserClient(owningTask, securityID, type, properties, handler); +} diff --git a/SoftU2FDriver/SoftU2FDriver.hpp b/SoftU2FDriver/SoftU2FDriver.hpp index 641e577..5f360cc 100644 --- a/SoftU2FDriver/SoftU2FDriver.hpp +++ b/SoftU2FDriver/SoftU2FDriver.hpp @@ -20,6 +20,8 @@ public : virtual bool start(IOService *provider) override; void free() override; IOWorkLoop* getWorkLoop() const override; + + virtual IOReturn newUserClient(task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) override; }; #endif /* SoftU2F_hpp */