RtkIPC

NOTE: The RtkIPC sample does not support the Windows 11 WDK (versions 22000 and above).

Description

This sample demonstrates usage of the Real-Time Kernel (RTK) API and how to synchronize a Windows driver with a RTX64 process. The RTK API is analogous to the existing RTX64 Real-Time (RT) API Inter-process communication (IPC) calls used within a Windows user mode application, but can be used by Windows kernel drivers. This example will demonstrate how to set up a Windows kernel driver so that it can access RTSS mutexes, events, semaphores, and shared memory.

This sample contains 3 projects for supported versions of Visual Studio.They are located under %public%\Public Documents\IntervalZero\RTX64 SDK\4.5\Samples\RtkIPC:

Source Files

File Description
RtkIPCDrv.sys Windows system file.
RtkIPCDrv.c Source file containing DriverEntry, which sets up threads to perform inter-process communication.
Thread.c Source file containing implementation of various thread handlers using RTKAPI to perform inter-process communication.
RtkRtssApp.rtss RTSS file.
RtkRtssApp.c Source file containing usage of RTAPI functions similar to what the RTKAPI functions use to perform Windows driver inter-process communication.
RtkIPCApp.exe Windows executable file.
RtkIPCApp.c Source file for a Windows console application that interfaces with RtkIpcDrv.sys and controls the startup and shutdown of the driver.

Instructions for Building and Setting up the RtkAPI Sample

NOTE: The driver in this sample must be built using the Windows Driver Kit (WDK) 10 1803.

  1. Launch Visual Studio and open the RtkIPC sample solution for your version of Visual Studio. For example, RtkIPC_VS2019.sln.
  2. Build the RtkIPCDrv.sys binary.
  3. Verify that RtkIPCDrv.sys was built without any errors.
  4. In order to load RtkIPCDrv.sys, make sure it is signed or disable signing.
  5. Install the driver using InstallDriver.bat.
  1. Build RtkRtssApp.rtss
  2. Build RtkWinApp.exe

NOTE: If you encounter errors relating to headers and libs while building RTK drivers, ensure that the installed versions of the WDK and Windows SDK match, and also ensure that the Target Platform Version setting in Visual Studio (Configuration Properties > General > Target Platform Version) is set to the correct version number.

Running RtkAPISample

  1. Start the Subsystem. You can do this directly from the Control Panel.
  2. Launch a Command Prompt as Administrator and navigate to the RtkIpcSample folder.
  3. Type ”RunWinApp start” to load RtkIpcDrv.sys.
  4. Run the test by issuing the following commands:
  5. To test mutex access, type “RunWinApp mutex”
  6. To test event access, type “RunWinApp event”
  7. To test semaphore access, type “RunWinApp semaphore”
  8. To test shared memory, type "RunWinApp shmem"
  9. Depending on the type of test you are running, you should see feedback from both the Windows driver and RtkRtssApp.rtss.
  10. After the test is complete, you may unload the Windows driver by typing “RunWinApp stop”.

IMPORTANT! Stopping the Subsystem is not sufficient to unload the driver. The driver requires the subsystem to be running in order to completely stop itself. The subsystem cannot be reloaded until it is completely unloaded. For this reason, step 6 must be completed before the subsystem is stopped or else a restart will be required before the subsystem can be started again.

APIs Referenced

RTKAPI

See Also

Windows Driver IPC API (RTKAPI) Overview