Search code examples
cwindowsserial-portkerneldevice-driver

Opening, reading, and writing to a serial port in the Windows kernel


I'm writing a Windows kernel driver in C and I need to send and receive data over a serial device, specifically COM3. I am stuck on the CreateFile, ReadFile, and WriteFile functions, as these seem to be user space functions that will not work in the kernel. Am I mistaken? Or if not, what is the best way to open and use a serial port from within the Windows kernel?

Many thanks.


Solution

  • You need ZwCreateFile, ZwReadFile and ZwWriteFile functions for working in kernel mode.