Why doesn't this keyboard intercepting kernel extension work?

前端 未结 1 1151
南方客
南方客 2021-02-02 04:28

my fellow developers! I hope very much that at least some of you will not get frightened by the amount of text this question contains (I simply did my best to be as descriptive

相关标签:
1条回答
  • 2021-02-02 04:50

    The problem is not with how you are overriding the existing IOHIDSystem instance. That works just fine.

    The problem is that when IOHIKeyboard is opened, it is passed a callback function to the IOHIDSystem for processing events. The callback is a static private function of IOHIDSystem, called _keyboardEvent:

        success = ((IOHIKeyboard*)source)->open(this, kIOServiceSeize,0,
                    (KeyboardEventCallback)        _keyboardEvent, 
                    (KeyboardSpecialEventCallback) _keyboardSpecialEvent,
                    (UpdateEventFlagsCallback)     _updateEventFlags);
    

    The callback then calls keyboardEvent function in the IOHIDSystem instance:

        self->keyboardEvent(eventType, flags, key, charCode, charSet,
                                origCharCode, origCharSet, keyboardType, repeat, ts, sender);
    

    It does not call the ten parameter one, which is virtual (and which you are overriding). Instead, what is being called is the 11 parameter non-virtual one. So even if you tried to override the 11 parameter one, it would not work as the call never goes through the vtable.

    0 讨论(0)
提交回复
热议问题