📄 test_xxgdrv.cpp
字号:
// the return value
//
void Test_XXGDRV_IOCTL_DRV_VERSION(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_DRV_VERSION) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_DRV_VERSION,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_DEV_VERSION
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_DEV_VERSION(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_DEV_VERSION) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_DEV_VERSION,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_SYS_INIT
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_SYS_INIT(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_SYS_INIT) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_SYS_INIT,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_DEV_INIT
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_DEV_INIT(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_DEV_INIT) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_DEV_INIT,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_READ_DATA
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_READ_DATA(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_READ_DATA) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_READ_DATA,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_WRITE_DATA
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_WRITE_DATA(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_WRITE_DATA) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_WRITE_DATA,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_SET_CMD
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_SET_CMD(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_SET_CMD) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_SET_CMD,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_GET_CMD
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_GET_CMD(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_GET_CMD) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_GET_CMD,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_CONTROL
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_CONTROL(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_CONTROL) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_CONTROL,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_ENABLE_ISO_MODE
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_ENABLE_ISO_MODE(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_ENABLE_ISO_MODE) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_ENABLE_ISO_MODE,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// Test_XXGDRV_IOCTL_READ_WRITE_REGISTER
//
// Test one Io Control Code
//
// TODO:
// Pass appropriate arguments to your device and check
// the return value
//
void Test_XXGDRV_IOCTL_READ_WRITE_REGISTER(void)
{
// Note that Input and Output are named from the point of view
// of the DEVICE:
// bufInput supplies data to the device
// bufOutput is written by the device to return data to this application
CHAR bufInput[IOCTL_INBUF_SIZE]; // Input to device
CHAR bufOutput[IOCTL_OUTBUF_SIZE]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (XXGDRV_IOCTL_READ_WRITE_REGISTER) in driver
printf("Issuing Ioctl to device - ");
if (!DeviceIoControl(hDevice,
XXGDRV_IOCTL_READ_WRITE_REGISTER,
bufInput,
IOCTL_INBUF_SIZE,
bufOutput,
IOCTL_OUTBUF_SIZE,
&nOutput,
NULL)
)
{
printf("ERROR: DeviceIoControl returns %0x.", GetLastError());
Exit(1);
}
}
////////////////////////////////////////////////////////////////////////
// ShowIoctlValues
//
// Print list of IO Control Code values for usage display
//
void ShowIoctlValues(void)
{
int i;
for (i=0; i<N_IOCODES; i++)
{
if (i==0)
printf( " IO control code index\n");
printf( " %d is code %s [%x]\n", i, IOnames[i], IOcodes[i]);
//=== Parameterized IOCTL Example ===
// if (IOcodes[i] == IOCTL_PARAMETERIZED)
// {
// printf( " and has two arguments: <arg1 desc.> <arg1 desc.>\n");
// printf( " Example: i %d <IOCTL index> <ex. arg1> <ex. arg2>\n", i);
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -