Character Device Modules

Character device modules are KLDs that create or install a character device. In FreeBSD, a character device is the interface for accessing a specific device within the kernel. For example, data is read from and written to the system console via the character device /dev/console.

Note

In Chapter 4 you'll be writing rootkits that hack the existing character devices on the system. Thus, this section serves as a primer.

There are three items that are unique to each character device module: a cdevsw structure, the character device functions, and a device registration routine. We'll discuss each in turn below.

The cdevsw Structure

A character device is defined by its entries in a character device switch table, struct cdevsw, which ...

Get Designing BSD Rootkits now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.