Author: tfaber
Date: Sun Apr 21 18:53:51 2013
New Revision: 58812
URL:
http://svn.reactos.org/svn/reactos?rev=58812&view=rev
Log:
[KMTESTS]
- Add KmtSendWStringToDriver to easily send unicode strings to special-purpose drivers
- Add TESTENTRY_NO_EXCLUSIVE_DEVICE flag for non-exclusive devices in special-purpose
drivers
ROSTESTS-104
Modified:
trunk/rostests/kmtests/include/kmt_test.h
trunk/rostests/kmtests/kmtest/support.c
trunk/rostests/kmtests/kmtest_drv/kmtest_standalone.c
Modified: trunk/rostests/kmtests/include/kmt_test.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/include/kmt_test.…
==============================================================================
--- trunk/rostests/kmtests/include/kmt_test.h [iso-8859-1] (original)
+++ trunk/rostests/kmtests/include/kmt_test.h [iso-8859-1] Sun Apr 21 18:53:51 2013
@@ -66,6 +66,7 @@
TESTENTRY_NO_CREATE_DEVICE = 1,
TESTENTRY_NO_REGISTER_DISPATCH = 2,
TESTENTRY_NO_REGISTER_UNLOAD = 4,
+ TESTENTRY_NO_EXCLUSIVE_DEVICE = 8,
} KMT_TESTENTRY_FLAGS;
NTSTATUS TestEntry(IN PDRIVER_OBJECT DriverObject, IN PCUNICODE_STRING RegistryPath, OUT
PCWSTR *DeviceName, IN OUT INT *Flags);
@@ -98,6 +99,7 @@
DWORD KmtSendToDriver(IN DWORD ControlCode);
DWORD KmtSendStringToDriver(IN DWORD ControlCode, IN PCSTR String);
+DWORD KmtSendWStringToDriver(IN DWORD ControlCode, IN PCWSTR String);
DWORD KmtSendBufferToDriver(IN DWORD ControlCode, IN OUT PVOID Buffer OPTIONAL, IN DWORD
InLength, IN OUT PDWORD OutLength);
#else /* if !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
#error either KMT_KERNEL_MODE or KMT_USER_MODE must be defined
Modified: trunk/rostests/kmtests/kmtest/support.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest/support.c?…
==============================================================================
--- trunk/rostests/kmtests/kmtest/support.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest/support.c [iso-8859-1] Sun Apr 21 18:53:51 2013
@@ -188,6 +188,31 @@
}
/**
+ * @name KmtSendStringToDriver
+ *
+ * Unload special-purpose driver (stop the service)
+ *
+ * @param ControlCode
+ * @param String
+ *
+ * @return Win32 error code as returned by DeviceIoControl
+ */
+DWORD
+KmtSendWStringToDriver(
+ IN DWORD ControlCode,
+ IN PCWSTR String)
+{
+ DWORD BytesRead;
+
+ assert(ControlCode < 0x400);
+
+ if (!DeviceIoControl(TestDeviceHandle, KMT_MAKE_CODE(ControlCode), (PVOID)String,
(DWORD)wcslen(String) * sizeof(WCHAR), NULL, 0, &BytesRead, NULL))
+ return GetLastError();
+
+ return ERROR_SUCCESS;
+}
+
+/**
* @name KmtSendBufferToDriver
*
* @param ControlCode
Modified: trunk/rostests/kmtests/kmtest_drv/kmtest_standalone.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/kmtest_drv/kmtest…
==============================================================================
--- trunk/rostests/kmtests/kmtest_drv/kmtest_standalone.c [iso-8859-1] (original)
+++ trunk/rostests/kmtests/kmtest_drv/kmtest_standalone.c [iso-8859-1] Sun Apr 21 18:53:51
2013
@@ -122,7 +122,8 @@
Status = IoCreateDevice(DriverObject, 0, &DeviceName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN | FILE_READ_ONLY_DEVICE,
- TRUE, &TestDeviceObject);
+ Flags & TESTENTRY_NO_EXCLUSIVE_DEVICE ? FALSE :
TRUE,
+ &TestDeviceObject);
if (!NT_SUCCESS(Status))
{