This is a simple Windows NT Console mode application that can be found in the SEC driver archive. It is presented here just to give a feel for how programs open the driver and issue commands to it. ---- cut here --- /* ** clear.c -- issue an SEC clear command ** Sample user mode (application space) program to test the device driver. */ #include #include #include #include "../include/secdrv.h" void main (void) { HANDLE hFile ; // handle to driver device SECDRV_IN args ; // argument buffer (unused in this case) SECDRV_OUT outBuffer ; // results buffer DWORD bytesReturned ; // # of bytes returned in outBuffer hFile = CreateFile (SEC_NAME, ETC_O) ; // Open the Device "file" if (hFile != INVALID_HANDLE_VALUE) { if (DeviceIoControl (hFile, (DWORD) SECDRV_CLEAR, // The clear command &args, // InBuffer SECDRV_INSIZE, // InBuffer size &outBuffer, // OutBuffer SECDRV_OUTSIZE, // OutBuffer size &bytesReturned, NULL)) // synchronous I/O { printf ("SEC Driver version %d.%d Counters cleared.", outBuffer.DriverVersion >> 8, outBuffer.DriverVersion & 0xFF) ; } else { printf ("DeviceIoControl error code = %ld\n", GetLastError()); printf ("Look it up in WINERROR.H\n"); /* ** For instance, if the call supplies a results buffer of the ** wrong length, the driver returns STATUS_INVALID_PARAMETER. ** Somebody or other translates it to ERROR_INVALID_PARAMETER, ** and it prints out as "error code = 87". */ } if (!CloseHandle (hFile)) printf ("Device close failed.\n") ; } else printf ("Device %s could not be opened\n", SEC_NAME) ; } /* ** End of user mode test program */