Simplest possible Mac OSX 'Hello World' kernel driver + console app

In Corso Pubblicato 7 anni fa Pagato alla consegna
In Corso Pagato alla consegna

Hello! I need the most basic possible ('skeleton' almost) "Hello World" type of app for OSX but for a driver, just to demonstrate how at its simplest an app can call a function in a driver.

I need this in C (not C++ or anything else) and assumingly compilable with gcc but im flexible there, in the form of 1) a simple kernel driver and 2) console app (no GUI or anything fancy like that required!) that calls it - both as simple as can be basically. 32bit + 64bit.

CONSOLE APP: When run it simply 1) unloads the driver (in case it was already previously loaded), 2) loads the driver, 3) calls a function in the driver, 4) prints the results to the console, and 5) unloads the driver.

DRIVER: The driver simply provides the app access to an internal but therefore 'exported' function like this: "int MyDriverFunction (*dword1, *dword2, *dword3)". When this function is accessed the driver simply writes 1 to *dword1, 2 to *dword3, and whatever happens to be in the edx/rdx register at the time (to demonstrate very basic use of inline asm).

Using the three dword pointers helps demonstrate the ability of the driver to return several data to the app. For the main function result the driver should return 0 if success or some error flag otherwise such as -1. And obviously being a driver it should clean up any memory it allocates, but that should be very simple given the simple nature of this!

Thankyou for reading, and I look forward to working with you! Please don't hesitate to ask any questions :)

OSX drivers are also known as a KERNEL EXTENSION (.kext file), for example http://osxdaily.com/2015/06/24/load-unload-kernel-extensions-mac-os-x/

This page has intro examples of both kernel drivers/extensions + usermode caller apps:
https://developer.apple.com/library/mac/referencelibrary/GettingStarted/GS_HardwareDrivers/_index.html

NOTE: The kernel extension/driver _CAN_ be written in C++ if C is not an option, BUT the userland caller console app MUST be in plain C.

The driver is preferably done in C not C++ though, and its certainly possible to do - this page provides a very simple Hello World OSX kernel example in C:
http://unixjunkie.blogspot.com.au/2006/12/kernel-extension-by-hand.html
So basically i need something similar to that - it might be a good starting base for you anyway.

Programmazione C Mac OS Programmazione Architettura Software

Rif. progetto: #10656266

Info sul progetto

2 proposte Progetto a distanza Attivo 7 anni fa