Listing 3: app.c Sending IOCTL commands
// app.c #include <windows.h> #include <winioctl.h> #include <stdio.h> #include "wdj.h" VOID __cdecl main(void) { HANDLE driver; ULONG value = 0, size = 0; driver = CreateFile("\\\\.\\wdjdrv", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (driver == INVALID_HANDLE_VALUE) { printf("Error opening wdj Driver (%d)\n", GetLastError()); return; } if (!DeviceIoControl(driver, (ULONG)IOCTL_WDJ_REQUEST, NULL, 0, &value, sizeof(ULONG), &size, NULL)) { printf("IOCTL_WDJ_REQUEST failed (%d)\n", GetLastError()); return; } CloseHandle(driver); printf("IOCTL_WDJ_REQUEST returned %d\n", value); } /* End of File */