Driver from C code (autoload, kext, lkm)

0

I've made a question on StackOverflow thinking it was the right place for asking, but they directed me here because they think its a SuperUser-releated topic. So here I am :)

I'd like to ask you how can I autoload my driver for a particular device on a Mac.

I have made a driver written in C, and now I was wondering how can I run this program in my macos(/linux/windows) environment whenever my device is plugged in. In short: how can I recognize, by system default, if this device is plugged to mac by vendor+product id( or to a linux or windows) and start my driver? Or how can I transform my C-driver in kext and autoload it? In lkm? (dll(?) for windows?)

Thanks you!

P.S. I know there are some specific OS-dependent APIs for kernel interaction, but for the moment I'd be grateful if I could load my C-driver from a "close-to-codeless" kernel extension, what I want to achieve is:

1 - When I plug my usb device, my system is able to recognize it
2 - my system load my custom kernel extension that ..
3 - ... will run my external C program to handle device.
(4- Of course when finishing, clean all)

Is it possibile or I have no choice than that to use Kernel APIs?

Thanks you so much!

pippo

Posted 2017-10-28T09:07:12.850

Reputation: 101

Do you want the answer for Windows, for Mac or for Linux? All answers will be different ... e.g. for Linux, look at udev. – dirkt – 2017-10-28T13:18:42.020

Mainly for Mac, but if you can provide me some useful tips about other OS I'll be grateful :) I'll look at udev as you said, thanks! – pippo – 2017-10-28T13:45:29.163

@pippo Good questions are not broad. Wanting a solution for everything makes it broad – Ramhound – 2017-10-28T15:22:30.803

No answers