[KMTEST_OLD]

- Remove kmtest_old and kmtloader as all their functionality is included in the new test suite

svn path=/branches/GSoC_2011/KMTestSuite/; revision=53639
This commit is contained in:
Thomas Faber
2011-09-08 10:44:26 +00:00
parent 2b6888164d
commit 5fc56f6309
25 changed files with 2 additions and 3089 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
add_subdirectory(apitests)
#add_subdirectory(dibtests)
add_subdirectory(drivers)
#add_subdirectory(drivers)
#add_subdirectory(dxtest)
add_subdirectory(kmtests)
#add_subdirectory(regtests)
@@ -9,5 +9,5 @@ if(NOT MSVC) # FIXME: msvc build
add_subdirectory(rosautotest)
endif()
add_subdirectory(tests)
add_subdirectory(win32)
#add_subdirectory(win32)
add_subdirectory(winetests)
-5
View File
@@ -1,5 +0,0 @@
#add_subdirectory(csqtest)
add_subdirectory(kmtest)
#add_subdirectory(memtest)
#add_subdirectory(ntoskrnl)
-6
View File
@@ -4,12 +4,6 @@
<directory name="csqtest">
<xi:include href="csqtest/csqtest.rbuild" />
</directory>
<directory name="kmtest">
<xi:include href="kmtest/kmtest.rbuild" />
</directory>
<directory name="kmtest">
<xi:include href="kmtest/kmtestassist.rbuild" />
</directory>
<directory name="memtest">
<xi:include href="memtest/memtest.rbuild" />
</directory>
-30
View File
@@ -1,30 +0,0 @@
list(APPEND KMTEST_SOURCE
kmtest.c
deviface_test.c
drvobj_test.c
devobj_test.c
reghelper.c
ntos_ex.c
ntos_io.c
ntos_ke.c
ntos_ob.c
ntos_pools.c
ntos_fsrtl.c
kmtest.rc)
add_library(kmtest_old SHARED ${KMTEST_SOURCE})
set_module_type(kmtest_old kernelmodedriver)
target_link_libraries(kmtest_old ${PSEH_LIB})
add_importlibs(kmtest_old ntoskrnl hal)
add_cd_file(TARGET kmtest_old DESTINATION reactos/system32/drivers FOR all)
add_library(kmtestassist SHARED kmtestassist.c)
set_module_type(kmtestassist kernelmodedriver)
add_importlibs(kmtestassist ntoskrnl hal)
add_cd_file(TARGET kmtestassist DESTINATION reactos/system32/drivers FOR all)
-141
View File
@@ -1,141 +0,0 @@
/*
* PnP Test
* Device Interface functions test
*
* Copyright 2004 Filip Navara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntifs.h>
#include <ndk/iotypes.h>
#include "kmtest.h"
#define NDEBUG
#include "debug.h"
/* PRIVATE FUNCTIONS **********************************************************/
NTSTATUS
(NTAPI *IoGetDeviceInterfaces_Func)(
IN CONST GUID *InterfaceClassGuid,
IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
IN ULONG Flags,
OUT PWSTR *SymbolicLinkList);
NTSTATUS NTAPI
ReactOS_IoGetDeviceInterfaces(
IN CONST GUID *InterfaceClassGuid,
IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
IN ULONG Flags,
OUT PWSTR *SymbolicLinkList);
VOID DeviceInterfaceTest_Func()
{
NTSTATUS Status;
PWSTR SymbolicLinkList;
PWSTR SymbolicLinkListPtr;
GUID Guid = {0x378de44c, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}};
Status = IoGetDeviceInterfaces(
&Guid,
NULL,
0,
&SymbolicLinkList);
ok(NT_SUCCESS(Status),
"IoGetDeviceInterfaces failed with status 0x%X\n",
(unsigned int)Status);
if (!NT_SUCCESS(Status))
{
return;
}
DPRINT("IoGetDeviceInterfaces results:\n");
for (SymbolicLinkListPtr = SymbolicLinkList;
SymbolicLinkListPtr[0] != 0 && SymbolicLinkListPtr[1] != 0;
SymbolicLinkListPtr += wcslen(SymbolicLinkListPtr) + 1)
{
DPRINT1("Symbolic Link: %S\n", SymbolicLinkListPtr);
}
#if 0
DPRINT("[PnP Test] Trying to get aliases\n");
for (SymbolicLinkListPtr = SymbolicLinkList;
SymbolicLinkListPtr[0] != 0 && SymbolicLinkListPtr[1] != 0;
SymbolicLinkListPtr += wcslen(SymbolicLinkListPtr) + 1)
{
UNICODE_STRING SymbolicLink;
UNICODE_STRING AliasSymbolicLink;
SymbolicLink.Buffer = SymbolicLinkListPtr;
SymbolicLink.Length = SymbolicLink.MaximumLength = wcslen(SymbolicLinkListPtr);
RtlInitUnicodeString(&AliasSymbolicLink, NULL);
IoGetDeviceInterfaceAlias(
&SymbolicLink,
&AliasGuid,
&AliasSymbolicLink);
if (AliasSymbolicLink.Buffer != NULL)
{
DPRINT("[PnP Test] Original: %S\n", SymbolicLinkListPtr);
DPRINT("[PnP Test] Alias: %S\n", AliasSymbolicLink.Buffer);
}
}
#endif
ExFreePool(SymbolicLinkList);
}
VOID RegisterDI_Test(HANDLE KeyHandle)
{
GUID Guid = {0x378de44c, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}};
DEVICE_OBJECT DeviceObject;
EXTENDED_DEVOBJ_EXTENSION DeviceObjectExtension;
DEVICE_NODE DeviceNode;
UNICODE_STRING SymbolicLinkName;
NTSTATUS Status;
StartTest();
RtlInitUnicodeString(&SymbolicLinkName, L"");
// Prepare our surrogate of a Device Object
DeviceObject.DeviceObjectExtension = (PDEVOBJ_EXTENSION)&DeviceObjectExtension;
// 1. DeviceNode = NULL
DeviceObjectExtension.DeviceNode = NULL;
Status = IoRegisterDeviceInterface(&DeviceObject, &Guid, NULL,
&SymbolicLinkName);
ok(Status == STATUS_INVALID_DEVICE_REQUEST,
"IoRegisterDeviceInterface returned 0x%08lX\n", Status);
// 2. DeviceNode->InstancePath is of a null length
DeviceObjectExtension.DeviceNode = &DeviceNode;
DeviceNode.InstancePath.Length = 0;
Status = IoRegisterDeviceInterface(&DeviceObject, &Guid, NULL,
&SymbolicLinkName);
ok(Status == STATUS_INVALID_DEVICE_REQUEST,
"IoRegisterDeviceInterface returned 0x%08lX\n", Status);
DeviceInterfaceTest_Func();
FinishTest(KeyHandle, L"IoDeviceInterfaceTest");
}
-266
View File
@@ -1,266 +0,0 @@
/*
* Driver Regression Tests
*
* Copyright 2009 Michael Martin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include "kmtest.h"
#include <ddk/ntddk.h>
#include <ddk/ntifs.h>
#include "ntddser.h"
#include "ntndk.h"
VOID LowerDeviceKernelAPITest(PDEVICE_OBJECT DeviceObject, BOOLEAN UnLoading)
{
PDEVICE_OBJECT RetObject;
RetObject = IoGetLowerDeviceObject(DeviceObject);
if (UnLoading)
{
ok(RetObject == 0,
"Expected no Lower DeviceObject, got %p", RetObject);
}
else
{
ok(RetObject == AttachDeviceObject,
"Expected an Attached DeviceObject %p, got %p", AttachDeviceObject, RetObject);
}
if (RetObject)
{
ObDereferenceObject(RetObject);
}
RetObject = IoGetDeviceAttachmentBaseRef(DeviceObject);
ok(RetObject == DeviceObject,
"Expected an Attached DeviceObject %p, got %p", DeviceObject, RetObject);
if (RetObject)
{
ObDereferenceObject(RetObject);
}
}
VOID DeviceCreatedTest(PDEVICE_OBJECT DeviceObject, BOOLEAN ExclusiveAccess)
{
PEXTENDED_DEVOBJ_EXTENSION extdev;
/*Check the device object members */
ok(DeviceObject->Type==3, "Expected Type = 3, got %x", DeviceObject->Type);
ok(DeviceObject->Size = 0xb8, "Expected Size = 0xba, got %x", DeviceObject->Size);
ok(DeviceObject->ReferenceCount == 0, "Expected ReferenceCount = 0, got %lu",
DeviceObject->ReferenceCount);
ok(DeviceObject->DriverObject == ThisDriverObject,
"Expected DriverObject member to match this DriverObject %p, got %p",
ThisDriverObject, DeviceObject->DriverObject);
ok(DeviceObject->NextDevice == NULL, "Expected NextDevice to be NULL, got %p", DeviceObject->NextDevice);
ok(DeviceObject->AttachedDevice == NULL, "Expected AttachDevice to be NULL, got %p", DeviceObject->AttachedDevice);
ok(DeviceObject->Characteristics == 0, "Expected Characteristics to be 0");
if (ExclusiveAccess)
{
ok((DeviceObject->Flags == (DO_DEVICE_HAS_NAME | DO_DEVICE_INITIALIZING | DO_EXCLUSIVE)),
"Expected Flags DO_DEVICE_HAS_NAME | DO_DEVICE_INITIALIZING | DO_EXCLUSIVE, got %lu", DeviceObject->Flags);
}
else
{
ok((DeviceObject->Flags == (DO_DEVICE_HAS_NAME | DO_DEVICE_INITIALIZING)),
"Expected Flags DO_DEVICE_HAS_NAME | DO_DEVICE_INITIALIZING, got %lu", DeviceObject->Flags);
}
ok(DeviceObject->DeviceType == FILE_DEVICE_UNKNOWN,
"Expected DeviceType to match creation parameter FILE_DEVICE_UNKNWOWN, got %lu",
DeviceObject->DeviceType);
ok(DeviceObject->ActiveThreadCount == 0, "Expected ActiveThreadCount = 0, got %lu\n", DeviceObject->ActiveThreadCount);
/*Check the extended extension */
extdev = (PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension;
ok(extdev->ExtensionFlags == 0, "Expected Extended ExtensionFlags to be 0, got %lu", extdev->ExtensionFlags);
ok (extdev->Type == 13, "Expected Type of 13, got %d", extdev->Type);
ok (extdev->Size == 0, "Expected Size of 0, got %d", extdev->Size);
ok (extdev->DeviceObject == DeviceObject, "Expected DeviceOject to match newly created device %p, got %p",
DeviceObject, extdev->DeviceObject);
ok(extdev->AttachedTo == NULL, "Expected AttachTo to be NULL, got %p", extdev->AttachedTo);
ok(extdev->StartIoCount == 0, "Expected StartIoCount = 0, got %lu", extdev->StartIoCount);
ok(extdev->StartIoKey == 0, "Expected StartIoKey = 0, got %lu", extdev->StartIoKey);
ok(extdev->StartIoFlags == 0, "Expected StartIoFlags = 0, got %lu", extdev->StartIoFlags);
}
VOID DeviceDeletionTest(PDEVICE_OBJECT DeviceObject, BOOLEAN Lower)
{
PEXTENDED_DEVOBJ_EXTENSION extdev;
/*Check the device object members */
ok(DeviceObject->Type==3, "Expected Type = 3, got %d", DeviceObject->Type);
ok(DeviceObject->Size = 0xb8, "Expected Size = 0xba, got %d", DeviceObject->Size);
ok(DeviceObject->ReferenceCount == 0, "Expected ReferenceCount = 0, got %lu",
DeviceObject->ReferenceCount);
if (!Lower)
{
ok(DeviceObject->DriverObject == ThisDriverObject,
"Expected DriverObject member to match this DriverObject %p, got %p",
ThisDriverObject, DeviceObject->DriverObject);
}
ok(DeviceObject->NextDevice == NULL, "Expected NextDevice to be NULL, got %p", DeviceObject->NextDevice);
if (Lower)
{
ok(DeviceObject->AttachedDevice == MainDeviceObject,
"Expected AttachDevice to be %p, got %p", MainDeviceObject, DeviceObject->AttachedDevice);
}
else
{
ok(DeviceObject->AttachedDevice == NULL, "Expected AttachDevice to be NULL, got %p", DeviceObject->AttachedDevice);
}
ok(DeviceObject->Flags ==FILE_VIRTUAL_VOLUME,
"Expected Flags FILE_VIRTUAL_VOLUME, got %lu", DeviceObject->Flags);
ok(DeviceObject->DeviceType == FILE_DEVICE_UNKNOWN,
"Expected DeviceType to match creation parameter FILE_DEVICE_UNKNWOWN, got %lu",
DeviceObject->DeviceType);
ok(DeviceObject->ActiveThreadCount == 0, "Expected ActiveThreadCount = 0, got %lu\n", DeviceObject->ActiveThreadCount);
/*Check the extended extension */
extdev = (PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension;
ok(extdev->ExtensionFlags == DOE_UNLOAD_PENDING,
"Expected Extended ExtensionFlags to be DOE_UNLOAD_PENDING, got %lu", extdev->ExtensionFlags);
ok (extdev->Type == 13, "Expected Type of 13, got %d", extdev->Type);
ok (extdev->Size == 0, "Expected Size of 0, got %d", extdev->Size);
ok (extdev->DeviceObject == DeviceObject, "Expected DeviceOject to match newly created device %p, got %p",
DeviceObject, extdev->DeviceObject);
if (Lower)
{
/* Skip this for now */
//ok(extdev->AttachedTo == MainDeviceObject, "Expected AttachTo to %p, got %p", MainDeviceObject, extdev->AttachedTo);
}
else
{
ok(extdev->AttachedTo == NULL, "Expected AttachTo to be NULL, got %p", extdev->AttachedTo);
}
ok(extdev->StartIoCount == 0, "Expected StartIoCount = 0, got %lu", extdev->StartIoCount);
ok(extdev->StartIoKey == 0, "Expected StartIoKey = 0, got %lu", extdev->StartIoKey);
ok(extdev->StartIoFlags == 0, "Expected StartIoFlags = 0, got %lu", extdev->StartIoFlags);
}
VOID DeviceCreateDeleteTest(PDRIVER_OBJECT DriverObject)
{
NTSTATUS Status;
UNICODE_STRING DeviceString;
UNICODE_STRING DosDeviceString;
PDEVICE_OBJECT DeviceObject;
/* Create using wrong directory */
RtlInitUnicodeString(&DeviceString, L"\\Device1\\Kmtest");
Status = IoCreateDevice(DriverObject,
0,
&DeviceString,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&DeviceObject);
ok(Status == STATUS_OBJECT_PATH_NOT_FOUND, "Expected STATUS_OBJECT_PATH_NOT_FOUND, got 0x%lX", Status);
/* Create using correct params with exlusice access */
RtlInitUnicodeString(&DeviceString, L"\\Device\\Kmtest");
Status = IoCreateDevice(DriverObject,
0,
&DeviceString,
FILE_DEVICE_UNKNOWN,
0,
TRUE,
&DeviceObject);
ok(Status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%lX", Status);
DeviceCreatedTest(DeviceObject, TRUE);
/* Delete the device */
if (NT_SUCCESS(Status))
{
IoDeleteDevice(DeviceObject);
ok(DriverObject->DeviceObject == 0, "Expected DriverObject->DeviceObject to be NULL, got %p",
DriverObject->DeviceObject);
}
/* Create using correct params with exlusice access */
Status = IoCreateDevice(DriverObject,
0,
&DeviceString,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&DeviceObject);
ok(Status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%lX", Status);
DeviceCreatedTest(DeviceObject, FALSE);
/* Delete the device */
if (NT_SUCCESS(Status))
{
IoDeleteDevice(DeviceObject);
ok(DriverObject->DeviceObject == 0, "Expected DriverObject->DeviceObject to be NULL, got %p",
DriverObject->DeviceObject);
}
/* Recreate device */
Status = IoCreateDevice(DriverObject,
0,
&DeviceString,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&DeviceObject);
ok(Status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%lX", Status);
RtlInitUnicodeString(&DosDeviceString, L"\\DosDevices\\kmtest");
Status = IoCreateSymbolicLink(&DosDeviceString, &DeviceString);
if (!NT_SUCCESS(Status))
{
/* Delete device object if not successful */
IoDeleteDevice(DeviceObject);
return;
}
MainDeviceObject = DeviceObject;
return;
}
BOOLEAN AttachDeviceTest(PDEVICE_OBJECT DeviceObject, PWCHAR NewDriverRegPath)
{
NTSTATUS Status;
UNICODE_STRING LowerDeviceName;
RtlInitUnicodeString(&LowerDeviceName, NewDriverRegPath);
Status = IoAttachDevice(DeviceObject, &LowerDeviceName, &AttachDeviceObject);
/* TODO: Add more tests */
return TRUE;
}
BOOLEAN DetachDeviceTest(PDEVICE_OBJECT AttachedDevice)
{
IoDetachDevice(AttachedDevice);
/* TODO: Add more tests */
return TRUE;
}
-141
View File
@@ -1,141 +0,0 @@
/*
* Driver Regression Tests
*
* Copyright 2009 Michael Martin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include "kmtest.h"
#include <ddk/ntddk.h>
#include <ddk/ntifs.h>
VOID DriverObjectTest(PDRIVER_OBJECT DriverObject, int DriverStatus)
{
BOOLEAN CheckThisDispatchRoutine;
PVOID FirstMajorFunc;
int i;
ok(DriverObject->Size == sizeof(DRIVER_OBJECT), "Size does not match, got %x",DriverObject->Size);
ok(DriverObject->Type == 4, "Type does not match 4. got %d",DriverObject->Type);
if (DriverStatus == 0)
{
ok(DriverObject->DeviceObject == NULL, "Expected DeviceObject pointer to be 0, got %p",
DriverObject->DeviceObject);
ok (DriverObject->Flags == DRVO_LEGACY_DRIVER,
"Expected Flags to be DRVO_LEGACY_DRIVER, got %lu",
DriverObject->Flags);
}
else if (DriverStatus == 1)
{
ok(DriverObject->DeviceObject != NULL, "Expected DeviceObject pointer to non null");
ok (DriverObject->Flags == (DRVO_LEGACY_DRIVER | DRVO_INITIALIZED),
"Expected Flags to be DRVO_LEGACY_DRIVER | DRVO_INITIALIZED, got %lu",
DriverObject->Flags);
}
else
{
ok(DriverObject->DeviceObject != NULL, "Expected DeviceObject pointer to non null");
ok (DriverObject->Flags == (DRVO_LEGACY_DRIVER | DRVO_INITIALIZED | DRVO_UNLOAD_INVOKED),
"Expected Flags to be DRVO_LEGACY_DRIVER | DRVO_INITIALIZED | DRVO_UNLOAD_INVOKED, got %lu",
DriverObject->Flags);
}
/* Select a routine that was not changed */
FirstMajorFunc = DriverObject->MajorFunction[1];
ok(FirstMajorFunc != 0, "Expected MajorFunction[1] to be non NULL");
if (FirstMajorFunc)
{
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
{
if (DriverStatus > 0) CheckThisDispatchRoutine = (i > 3) && (i != 14);
else CheckThisDispatchRoutine = TRUE;
if (CheckThisDispatchRoutine)
{
ok(DriverObject->MajorFunction[i] == FirstMajorFunc, "Expected MajorFunction[%d] to match %p",
i, FirstMajorFunc);
}
}
}
else
{
ok(TRUE, "Skipped testing for all MajorFunction");
}
}
BOOLEAN ZwLoadTest(PDRIVER_OBJECT DriverObject, PUNICODE_STRING DriverRegistryPath, PWCHAR NewDriverRegPath)
{
UNICODE_STRING RegPath;
NTSTATUS Status;
/* Try to load ourself */
Status = ZwLoadDriver(DriverRegistryPath);
ok (Status == STATUS_IMAGE_ALREADY_LOADED, "Expected NTSTATUS STATUS_IMAGE_ALREADY_LOADED, got 0x%lX", Status);
if (Status != STATUS_IMAGE_ALREADY_LOADED)
{
DbgPrint("WARNING: Loading this a second time will cause BUGCHECK!\n");
}
/* Try to load with a Registry Path that doesnt exist */
RtlInitUnicodeString(&RegPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\deadbeef");
Status = ZwLoadDriver(&RegPath);
ok (Status == STATUS_OBJECT_NAME_NOT_FOUND, "Expected NTSTATUS STATUS_OBJECT_NAME_NOT_FOUND, got 0x%lX", Status);
/* Load the driver */
RtlInitUnicodeString(&RegPath, NewDriverRegPath);
Status = ZwLoadDriver(&RegPath);
ok(Status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%lX", Status);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
return TRUE;
}
BOOLEAN ZwUnloadTest(PDRIVER_OBJECT DriverObject, PUNICODE_STRING DriverRegistryPath, PWCHAR NewDriverRegPath)
{
UNICODE_STRING RegPath;
NTSTATUS Status;
/* Try to unload ourself, which should fail as our Unload routine hasnt been set yet. */
Status = ZwUnloadDriver(DriverRegistryPath);
ok (Status == STATUS_INVALID_DEVICE_REQUEST, "Expected NTSTATUS STATUS_INVALID_DEVICE_REQUEST, got 0x%lX", Status);
/* Try to unload with a Registry Path that doesnt exist */
RtlInitUnicodeString(&RegPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\deadbeef");
Status = ZwUnloadDriver(&RegPath);
ok (Status == STATUS_OBJECT_NAME_NOT_FOUND, "Expected NTSTATUS STATUS_OBJECT_NAME_NOT_FOUND, got 0x%lX", Status);
/* Unload the driver */
RtlInitUnicodeString(&RegPath, NewDriverRegPath);
Status = ZwUnloadDriver(&RegPath);
ok(Status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%lX", Status);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
return TRUE;
}
-526
View File
@@ -1,526 +0,0 @@
/*
* Kernel Mode regression Test
* Driver Core
*
* Copyright 2004 Filip Navara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntddk.h>
#include "kmtest.h"
#define NDEBUG
#include <debug.h>
LONG successes;
LONG failures;
LONG skipped;
tls_data glob_data;
/* PRIVATE FUNCTIONS ***********************************************************/
VOID
StartTest()
{
successes = 0;
failures = 0;
skipped = 0;
}
VOID
FinishTest(HANDLE KeyHandle, LPWSTR TestName)
{
WCHAR KeyName[100];
LONG total = successes + failures;
UNICODE_STRING KeyNameU;
wcscpy(KeyName, TestName);
wcscat(KeyName, L"SuccessCount");
RtlInitUnicodeString(&KeyNameU, KeyName);
ZwSetValueKey(KeyHandle,
&KeyNameU,
0,
REG_DWORD,
&successes,
sizeof(ULONG));
wcscpy(KeyName, TestName);
wcscat(KeyName, L"FailureCount");
RtlInitUnicodeString(&KeyNameU, KeyName);
ZwSetValueKey(KeyHandle,
&KeyNameU,
0,
REG_DWORD,
&failures,
sizeof(ULONG));
wcscpy(KeyName, TestName);
wcscat(KeyName, L"TotalCount");
RtlInitUnicodeString(&KeyNameU, KeyName);
ZwSetValueKey(KeyHandle,
&KeyNameU,
0,
REG_DWORD,
&total,
sizeof(ULONG));
wcscpy(KeyName, TestName);
wcscat(KeyName, L"SkipCount");
RtlInitUnicodeString(&KeyNameU, KeyName);
ZwSetValueKey(KeyHandle,
&KeyNameU,
0,
REG_DWORD,
&skipped,
sizeof(ULONG));
DbgPrint("%S: %d test executed (0 marked as todo, %d failures), %d skipped.\n", TestName, total, failures, skipped);
}
void kmtest_set_location(const char* file, int line)
{
glob_data.current_file=strrchr(file,'/');
if (glob_data.current_file==NULL)
glob_data.current_file=strrchr(file,'\\');
if (glob_data.current_file==NULL)
glob_data.current_file=file;
else
glob_data.current_file++;
glob_data.current_line=line;
}
/*
* Checks condition.
* Parameters:
* - condition - condition to check;
* - msg test description;
* - file - test application source code file name of the check
* - line - test application source code file line number of the check
* Return:
* 0 if condition does not have the expected value, 1 otherwise
*/
int kmtest_ok(int condition, const char *msg, ... )
{
va_list valist;
if (!condition)
{
if (msg[0])
{
char string[1024];
va_start(valist, msg);
vsprintf(string, msg, valist);
DbgPrint( "%s:%d: Test failed: %s\n",
glob_data.current_file, glob_data.current_line, string );
va_end(valist);
}
else
{
DbgPrint( "%s:%d: Test failed\n",
glob_data.current_file, glob_data.current_line );
}
InterlockedIncrement(&failures);
return 0;
}
else
{/*
if (report_success)
fprintf( stdout, "%s:%d: Test succeeded\n",
glob_data.current_file, glob_data.current_line);*/
InterlockedIncrement(&successes);
}
return 1;
}
/* PUBLIC FUNCTIONS ***********************************************************/
PWCHAR CreateLowerDeviceRegistryKey(PUNICODE_STRING RegistryPath, PWCHAR NewDriver);
/*
* Test Declarations
*/
VOID RegisterDI_Test(HANDLE KeyHandle);
VOID NtoskrnlIoMdlTest(HANDLE KeyHandle);
VOID NtoskrnlIoIrpTest(HANDLE KeyHandle);
VOID NtoskrnlObTest(HANDLE KeyHandle);
VOID ExTimerTest(HANDLE KeyHandle);
VOID PoolsTest(HANDLE KeyHandle);
VOID PoolsCorruption(HANDLE KeyHandle);
VOID KeStallTest(HANDLE KeyHandle);
VOID DriverObjectTest(PDRIVER_OBJECT, int);
VOID DeviceCreateDeleteTest(PDRIVER_OBJECT);
VOID DeviceObjectTest(PDEVICE_OBJECT);
BOOLEAN ZwLoadTest(PDRIVER_OBJECT, PUNICODE_STRING, PWCHAR);
BOOLEAN ZwUnloadTest(PDRIVER_OBJECT, PUNICODE_STRING, PWCHAR);
BOOLEAN DetachDeviceTest(PDEVICE_OBJECT);
BOOLEAN AttachDeviceTest(PDEVICE_OBJECT, PWCHAR);
VOID LowerDeviceKernelAPITest(PDEVICE_OBJECT, BOOLEAN);
VOID NtoskrnlFsRtlTest(HANDLE KeyHandle);
typedef enum {
TestStageExTimer = 0,
TestStageIoMdl,
TestStageIoDi,
TestStageIoIrp,
TestStageMmPoolTest,
TestStageMmPoolCorruption,
TestStageOb,
TestStageKeStall,
TestStageDrv,
TestStageFsRtl,
TestStageMax
} TEST_STAGE;
/*
* KmtestDispatch
*/
NTSTATUS
NTAPI
KmtestDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
NTSTATUS Status = STATUS_SUCCESS;
if (AttachDeviceObject)
{
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(AttachDeviceObject, Irp);
return Status;
}
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
/*
* KmtestCreateClose
*/
NTSTATUS
NTAPI
KmtestCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
NTSTATUS Status = STATUS_SUCCESS;
if (AttachDeviceObject)
{
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(AttachDeviceObject, Irp);
return Status;
}
/* Do DriverObject Test with Driver Initialized */
DriverObjectTest(DeviceObject->DriverObject, 1);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information=0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
/*
* KmtestUnload
*/
VOID
NTAPI
KmtestUnload(IN PDRIVER_OBJECT DriverObject)
{
UNICODE_STRING DosDeviceString;
if(AttachDeviceObject)
{
IoDetachDevice(AttachDeviceObject);
}
/* Do DriverObject Test for Unload */
DriverObjectTest(DriverObject, 2);
if (MainDeviceObject)
{
RtlInitUnicodeString(&DosDeviceString, L"\\DosDevices\\Kmtest");
IoDeleteSymbolicLink(&DosDeviceString);
IoDeleteDevice(MainDeviceObject);
}
}
static
PKEY_VALUE_PARTIAL_INFORMATION
NTAPI
ReadRegistryValue(HANDLE KeyHandle, PWCHAR ValueName)
{
NTSTATUS Status;
PKEY_VALUE_PARTIAL_INFORMATION InformationBuffer = NULL;
ULONG AllocatedLength = 0, RequiredLength = 0;
UNICODE_STRING ValueNameU;
RtlInitUnicodeString(&ValueNameU, ValueName);
Status = ZwQueryValueKey(KeyHandle,
&ValueNameU,
KeyValuePartialInformation,
NULL,
0,
&RequiredLength);
if (Status == STATUS_BUFFER_TOO_SMALL || Status == STATUS_BUFFER_OVERFLOW)
{
InformationBuffer = ExAllocatePool(PagedPool, RequiredLength);
AllocatedLength = RequiredLength;
if (!InformationBuffer) return NULL;
Status = ZwQueryValueKey(KeyHandle,
&ValueNameU,
KeyValuePartialInformation,
InformationBuffer,
AllocatedLength,
&RequiredLength);
}
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to read %S (0x%x)\n", ValueName, Status);
if (InformationBuffer != NULL)
ExFreePool(InformationBuffer);
return NULL;
}
return InformationBuffer;
}
static
VOID
RunKernelModeTest(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath,
HANDLE KeyHandle,
TEST_STAGE Stage)
{
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"CurrentStage");
PWCHAR LowerDriverRegPath;
DPRINT1("Running stage %d test...\n", Stage);
ZwSetValueKey(KeyHandle,
&KeyName,
0,
REG_DWORD,
&Stage,
sizeof(ULONG));
switch (Stage)
{
case TestStageExTimer:
ExTimerTest(KeyHandle);
break;
case TestStageIoMdl:
NtoskrnlIoMdlTest(KeyHandle);
break;
case TestStageIoDi:
RegisterDI_Test(KeyHandle);
break;
case TestStageIoIrp:
NtoskrnlIoIrpTest(KeyHandle);
break;
case TestStageMmPoolTest:
PoolsTest(KeyHandle);
break;
case TestStageMmPoolCorruption:
PoolsCorruption(KeyHandle);
break;
case TestStageOb:
NtoskrnlObTest(KeyHandle);
break;
case TestStageKeStall:
KeStallTest(KeyHandle);
break;
case TestStageDrv:
/* Start the tests for the driver routines */
StartTest();
/* Do DriverObject Test for Driver Entry */
DriverObjectTest(DriverObject, 0);
/* Create and delete device, on return MainDeviceObject has been created */
DeviceCreateDeleteTest(DriverObject);
/* Make sure a device object was created */
if (MainDeviceObject)
{
LowerDriverRegPath = CreateLowerDeviceRegistryKey(RegistryPath, L"kmtestassist");
if (LowerDriverRegPath)
{
/* Load driver test and load the lower driver */
if (ZwLoadTest(DriverObject, RegistryPath, LowerDriverRegPath))
{
AttachDeviceTest(MainDeviceObject, L"kmtestassists");
if (AttachDeviceObject)
{
LowerDeviceKernelAPITest(MainDeviceObject, FALSE);
}
/* Unload lower driver without detaching from its device */
ZwUnloadTest(DriverObject, RegistryPath, LowerDriverRegPath);
LowerDeviceKernelAPITest(MainDeviceObject, TRUE);
}
else
{
DbgPrint("Failed to load kmtestassist driver\n");
}
}
}
FinishTest(KeyHandle, L"DriverTest");
break;
case TestStageFsRtl:
NtoskrnlFsRtlTest(KeyHandle);
break;
default:
ASSERT(FALSE);
break;
}
}
/*
* DriverEntry
*/
NTSTATUS
NTAPI
DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
{
int i;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING ParameterKeyName = RTL_CONSTANT_STRING(L"Parameters");
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
PULONG KeyValue;
TEST_STAGE CurrentStage;
HANDLE DriverKeyHandle, ParameterKeyHandle;
DbgPrint("\n===============================================\n");
DbgPrint("Kernel Mode Regression Driver Test starting...\n");
DbgPrint("===============================================\n");
InitializeObjectAttributes(&ObjectAttributes,
RegistryPath,
OBJ_CASE_INSENSITIVE,
0,
NULL);
Status = ZwOpenKey(&DriverKeyHandle,
KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open %wZ\n", RegistryPath);
return Status;
}
InitializeObjectAttributes(&ObjectAttributes,
&ParameterKeyName,
OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
DriverKeyHandle,
NULL);
Status = ZwCreateKey(&ParameterKeyHandle,
KEY_SET_VALUE | KEY_QUERY_VALUE,
&ObjectAttributes,
0,
NULL,
REG_OPTION_NON_VOLATILE,
NULL);
ZwClose(DriverKeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create %wZ\\%wZ\n", RegistryPath, &ParameterKeyName);
return Status;
}
KeyInfo = ReadRegistryValue(ParameterKeyHandle, L"CurrentStage");
if (KeyInfo)
{
if (KeyInfo->DataLength != sizeof(ULONG))
{
DPRINT1("Invalid data length for CurrentStage: %d\n", KeyInfo->DataLength);
ExFreePool(KeyInfo);
return STATUS_UNSUCCESSFUL;
}
KeyValue = (PULONG)KeyInfo->Data;
if ((*KeyValue) + 1 < TestStageMax)
{
DPRINT1("Resuming testing after a crash at stage %d\n", (*KeyValue));
CurrentStage = (TEST_STAGE)((*KeyValue) + 1);
}
else
{
DPRINT1("Testing was completed on a previous boot\n");
ExFreePool(KeyInfo);
return STATUS_UNSUCCESSFUL;
}
ExFreePool(KeyInfo);
}
else
{
DPRINT1("Starting a fresh test\n");
CurrentStage = (TEST_STAGE)0;
}
/* Run the tests */
while (CurrentStage < TestStageMax)
{
RunKernelModeTest(DriverObject,
RegistryPath,
ParameterKeyHandle,
CurrentStage);
CurrentStage++;
}
DPRINT1("Testing is complete!\n");
ZwClose(ParameterKeyHandle);
/* Set all MajorFunctions to NULL to verify that kernel fixes them */
for (i = 1; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
DriverObject->MajorFunction[i] = NULL;
/* Set necessary routines */
DriverObject->DriverUnload = KmtestUnload;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = KmtestDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = KmtestCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = KmtestCreateClose;
return STATUS_SUCCESS;
}
-54
View File
@@ -1,54 +0,0 @@
#ifndef KMTEST_H
#define KMTEST_H
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "ntddk.h"
/*
Some macros, structs, and vars are based or inspired from the great
Wine regression tests Copyright (C) 2002 Alexandre Julliard.
Everything else is done by Aleksey Bragin based on PnPTest by Filip Navara
*/
extern LONG successes; /* number of successful tests */
extern LONG failures; /* number of failures */
//static ULONG todo_successes; /* number of successful tests inside todo block */
//static ULONG todo_failures; /* number of failures inside todo block */
// We don't do multithreading, so we just keep this struct in a global var
typedef struct
{
const char* current_file; /* file of current check */
int current_line; /* line of current check */
int todo_level; /* current todo nesting level */
int todo_do_loop;
} tls_data;
extern tls_data glob_data;
VOID StartTest(VOID);
VOID FinishTest(HANDLE KeyHandle, LPWSTR TestName);
void kmtest_set_location(const char* file, int line);
#ifdef __GNUC__
extern int kmtest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
#else /* __GNUC__ */
extern int kmtest_ok( int condition, const char *msg, ... );
#endif /* __GNUC__ */
#define ok_(file, line) (kmtest_set_location(file, line), 0) ? (void)0 : kmtest_ok
#define ok ok_(__FILE__, __LINE__)
PDEVICE_OBJECT AttachDeviceObject;
PDEVICE_OBJECT MainDeviceObject;
PDRIVER_OBJECT ThisDriverObject;
#endif /* KMTEST_H */
-19
View File
@@ -1,19 +0,0 @@
<module name="kmtest_old" type="kernelmodedriver" installbase="system32/drivers" installname="kmtest_old.sys">
<bootstrap base="$(CDOUTPUT)" />
<include base="ReactOS">include/reactos/drivers</include>
<library>ntoskrnl</library>
<library>hal</library>
<library>pseh</library>
<file>kmtest.c</file>
<file>deviface_test.c</file>
<file>drvobj_test.c</file>
<file>devobj_test.c</file>
<file>reghelper.c</file>
<file>ntos_ex.c</file>
<file>ntos_io.c</file>
<file>ntos_ke.c</file>
<file>ntos_ob.c</file>
<file>ntos_pools.c</file>
<file>ntos_fsrtl.c</file>
<file>kmtest.rc</file>
</module>
-7
View File
@@ -1,7 +0,0 @@
/* $Id: csqtest.rc 21842 2006-05-07 19:16:11Z ion $ */
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "Kernel Mode Regression Tests\0"
#define REACTOS_STR_INTERNAL_NAME "kmtest\0"
#define REACTOS_STR_ORIGINAL_FILENAME "kmtest.sys\0"
#include <reactos/version.rc>
-97
View File
@@ -1,97 +0,0 @@
/*
* Driver Regression Tests
*
* Copyright 2009 Michael Martin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include "ntddk.h"
#include "ntddser.h"
NTSTATUS
NTAPI
DriverDispatch(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
{
DbgPrint(" ControlCode %x\n",IoGetCurrentIrpStackLocation(Irp)->Parameters.DeviceIoControl.IoControlCode);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information=0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
DriverCreateClose(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
{
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
VOID
NTAPI
DriverUnload(IN PDRIVER_OBJECT DriverObject)
{
UNICODE_STRING DeviceString;
RtlInitUnicodeString(&DeviceString, L"\\DosDevices\\kmtestassist");
IoDeleteSymbolicLink(&DeviceString);
IoDeleteDevice(DriverObject->DeviceObject);
}
NTSTATUS
NTAPI
DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING path)
{
PDEVICE_OBJECT pDeviceObject;
UNICODE_STRING DriverString;
UNICODE_STRING DeviceString;
NTSTATUS Status= STATUS_DEVICE_CONFIGURATION_ERROR;
RtlInitUnicodeString(&DriverString, L"\\Device\\kmtestassist");
Status = IoCreateDevice(DriverObject,0,&DriverString,FILE_DEVICE_UNKNOWN,0,FALSE,&pDeviceObject);
if (!NT_SUCCESS(Status))
{
return Status;
}
RtlInitUnicodeString(&DeviceString, L"\\DosDevices\\kmtestassist");
Status = IoCreateSymbolicLink(&DeviceString, &DriverString);
if (!NT_SUCCESS(Status))
{
// Delete device object if not successful
IoDeleteDevice(pDeviceObject);
return Status;
}
DriverObject->DriverUnload = DriverUnload;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DriverDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = DriverCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = DriverCreateClose;
return Status;
}
-7
View File
@@ -1,7 +0,0 @@
<module name="kmtestassist" type="kernelmodedriver" installbase="system32/drivers" installname="kmtestassist.sys">
<bootstrap base="$(CDOUTPUT)" />
<include base="ReactOS">include/reactos/drivers</include>
<library>ntoskrnl</library>
<library>hal</library>
<file>kmtestassist.c</file>
</module>
-172
View File
@@ -1,172 +0,0 @@
/*
* NTOSKRNL Executive Regressions KM-Test
* ReactOS Kernel Mode Regression Testing framework
*
* Copyright 2006 Aleksey Bragin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntddk.h>
#include <ntifs.h>
#include <ndk/ntndk.h>
#include "kmtest.h"
#define NDEBUG
#include "debug.h"
/* PRIVATE FUNCTIONS ***********************************************************/
VOID
NTAPI
TestTimerApcRoutine(IN PVOID TimerContext,
IN ULONG TimerLowValue,
IN LONG TimerHighValue)
{
ULONG *ApcCount = (ULONG *)TimerContext;
DPRINT("Timer Apc called!\n");
(*ApcCount)++;
}
/* PUBLIC FUNCTIONS *************************************************************/
VOID
ExTimerTest(HANDLE KeyHandle)
{
UNICODE_STRING TimerName;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE TimerHandle;
HANDLE HandleOpened;
LARGE_INTEGER DueTime;
BOOLEAN PreviousState, CurrentState;
NTSTATUS Status;
ULONG ApcCount;
StartTest();
// Create the timer
RtlInitUnicodeString(&TimerName, L"\\TestTimer");
InitializeObjectAttributes(&ObjectAttributes, &TimerName, 0, NULL, NULL);
Status = ZwCreateTimer(&TimerHandle, TIMER_ALL_ACCESS,
&ObjectAttributes, NotificationTimer);
ok(Status == STATUS_SUCCESS, "ZwCreateTimer failed with Status=0x%08lX", Status);
// Open the timer
Status = ZwOpenTimer(&HandleOpened, TIMER_ALL_ACCESS, &ObjectAttributes);
ok(Status == STATUS_SUCCESS, "ZwOpenTimer failed with Status=0x%08lX", Status);
// Set the timer, to some rather high value so it doesn't expire
DPRINT("Set timer 1\n");
DueTime.LowPart = -10000;
DueTime.HighPart = -10;
PreviousState = TRUE;
Status = ZwSetTimer(HandleOpened, &DueTime, NULL, NULL, FALSE, 0L, &PreviousState);
ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);
ok(PreviousState == FALSE, "Incorrect PreviousState returned when setting the timer");
// Cancel the timer
CurrentState = TRUE;
Status = ZwCancelTimer(HandleOpened, &CurrentState);
ok(Status == STATUS_SUCCESS, "ZwCancelTimer failed with Status=0x%08lX", Status);
ok(CurrentState == FALSE, "Incorrect CurrentState returned when canceling the timer");
// Set the timer to some small value, because we'll wait for it to expire
DPRINT("Set timer 2\n");
DueTime.LowPart = -100;
DueTime.HighPart = -1;
PreviousState = TRUE;
Status = ZwSetTimer(HandleOpened, &DueTime, NULL, NULL, FALSE, 0L, &PreviousState);
ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);
ok(PreviousState == FALSE, "Incorrect PreviousState returned when setting the timer");
// Wait until it expires
DPRINT("Wait till timer expires\n");
Status = ZwWaitForSingleObject(HandleOpened, FALSE, NULL);
ok(Status == STATUS_SUCCESS, "ZwWaitForSingleObject failed with Status=0x%08lX", Status);
// And cancel it
DPRINT("Cancel it\n");
CurrentState = FALSE;
Status = ZwCancelTimer(HandleOpened, &CurrentState);
ok(Status == STATUS_SUCCESS, "ZwCancelTimer failed with Status=0x%08lX", Status);
ok(CurrentState == TRUE, "Incorrect CurrentState returned when setting the timer");
// Test it with APC: Set, Cancel, check if APC has been called
DPRINT("Set timer with Apc (3)\n");
ApcCount = 0;
DueTime.LowPart = -10000;
DueTime.HighPart = -10;
PreviousState = FALSE;
Status = ZwSetTimer(HandleOpened, &DueTime,
(PTIMER_APC_ROUTINE)TestTimerApcRoutine, &ApcCount, FALSE,
0L, &PreviousState);
ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);
ok(PreviousState == TRUE, "Incorrect PreviousState returned when setting the timer");
DPRINT("Cancel it\n");
CurrentState = TRUE;
Status = ZwCancelTimer(HandleOpened, &CurrentState);
ok(Status == STATUS_SUCCESS, "ZwCancelTimer failed with Status=0x%08lX", Status);
ok(CurrentState == FALSE, "Incorrect CurrentState returned when cancelling the timer");
ok(ApcCount == 0, "Incorrect count of TimerApcRoutine calls: %ld, should be 0\n", ApcCount);
// Test setting the timer two times in a row, APC routine must not be called
DPRINT("Set timer with Apc (4)\n");
ApcCount = 0;
DueTime.LowPart = -10000;
DueTime.HighPart = -10;
PreviousState = TRUE;
Status = ZwSetTimer(HandleOpened, &DueTime,
(PTIMER_APC_ROUTINE)TestTimerApcRoutine, &ApcCount, FALSE,
0L, &PreviousState);
ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);
ok(PreviousState == FALSE, "Incorrect PreviousState returned when setting the timer");
// Set small due time, since we have to wait for timer to finish
DPRINT("Set timer with Apc (5)\n");
DueTime.LowPart = -10;
DueTime.HighPart = -1;
PreviousState = TRUE;
Status = ZwSetTimer(HandleOpened, &DueTime,
(PTIMER_APC_ROUTINE)TestTimerApcRoutine, &ApcCount, FALSE,
0L, &PreviousState);
ok(Status == STATUS_SUCCESS, "ZwSetTimer failed with Status=0x%08lX", Status);
ok(PreviousState == FALSE, "Incorrect PreviousState returned when setting the timer");
// Now wait till it's finished, and then check APC call
DPRINT("Wait for it\n");
Status = ZwWaitForSingleObject(HandleOpened, FALSE, NULL);
ok(Status == STATUS_SUCCESS, "ZwWaitForSingleObject failed with Status=0x%08lX", Status);
CurrentState = FALSE;
Status = ZwCancelTimer(HandleOpened, &CurrentState);
ok(Status == STATUS_SUCCESS, "ZwCancelTimer failed with Status=0x%08lX", Status);
ok(CurrentState == TRUE, "Incorrect CurrentState returned when cancelling the timer");
ok(ApcCount == 1, "Incorrect count of TimerApcRoutine calls: %ld, should be 1\n", ApcCount);
// Cleanup...
Status = ZwClose(HandleOpened);
ok(Status == STATUS_SUCCESS, "ZwClose failed with Status=0x%08lX", Status);
Status = ZwClose(TimerHandle);
ok(Status == STATUS_SUCCESS, "ZwClose failed with Status=0x%08lX", Status);
FinishTest(KeyHandle, L"ExTimerTest");
}
-343
View File
@@ -1,343 +0,0 @@
/*
* FsRtl Test
*
* Copyright 2010 Pierre Schweitzer <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include "kmtest.h"
#include <ntifs.h>
#define NDEBUG
#include "debug.h"
/* PRIVATE FUNCTIONS **********************************************************/
VOID FsRtlIsNameInExpressionTest()
{
UNICODE_STRING Expression, Name;
RtlInitUnicodeString(&Expression, L"*");
RtlInitUnicodeString(&Name, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"ntdll.dll");
RtlInitUnicodeString(&Name, L".");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"~1");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"..");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"ntdll.dll");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"smss.exe");
RtlInitUnicodeString(&Name, L".");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"~1");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"..");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"ntdll.dll");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"NTDLL.dll");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"nt??krnl.???");
RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"he*o");
RtlInitUnicodeString(&Name, L"hello");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"helo");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"hella");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"he*");
RtlInitUnicodeString(&Name, L"hello");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"helo");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"hella");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"*.cpl");
RtlInitUnicodeString(&Name, L"kdcom.dll");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"bootvid.dll");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L".");
RtlInitUnicodeString(&Name, L"NTDLL.DLL");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"F0_*.*");
RtlInitUnicodeString(&Name, L".");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"..");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"SETUP.EXE");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"F0_001");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"*.TTF");
RtlInitUnicodeString(&Name, L".");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"..");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"SETUP.INI");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"*");
RtlInitUnicodeString(&Name, L".");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"..");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"SETUP.INI");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"\"ntoskrnl.exe");
RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"ntoskrnl\"exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"ntoskrn\".exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"ntoskrn\"\"exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"ntoskrnl.\"exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"ntoskrnl.exe\"");
RtlInitUnicodeString(&Name, L"ntoskrnl.exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"ntoskrnl.exe.");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"*.c.d");
RtlInitUnicodeString(&Name, L"a.b.c.d");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"*.?.c.d");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"*?");
RtlInitUnicodeString(&Name, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"a");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"aa");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"aaa");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"?*?");
RtlInitUnicodeString(&Name, L"");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"a");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Name, L"aa");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"aaa");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Name, L"aaaa");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
/* Tests from #5923 */
RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\**");
RtlInitUnicodeString(&Name, L"C:\\ReactOS\\dings.bmp");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\***");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE");
RtlInitUnicodeString(&Expression, L"C:\\Windows\\*a*");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\*.bmp");
RtlInitUnicodeString(&Name, L"C:\\Windows\\explorer.exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
RtlInitUnicodeString(&Expression, L"*.bmp;*.dib");
RtlInitUnicodeString(&Name, L"winhlp32.exe");
ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE");
}
VOID FsRtlIsDbcsInExpressionTest()
{
ANSI_STRING Expression, Name;
RtlInitAnsiString(&Expression, "*");
RtlInitAnsiString(&Name, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "ntdll.dll");
RtlInitAnsiString(&Name, ".");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "~1");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "..");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "ntdll.dll");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "smss.exe");
RtlInitAnsiString(&Name, ".");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "~1");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "..");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "ntdll.dll");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "NTDLL.dll");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "nt??krnl.???");
RtlInitAnsiString(&Name, "ntoskrnl.exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "he*o");
RtlInitAnsiString(&Name, "hello");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "helo");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "hella");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "he*");
RtlInitAnsiString(&Name, "hello");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "helo");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "hella");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "*.cpl");
RtlInitAnsiString(&Name, "kdcom.dll");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "bootvid.dll");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "ntoskrnl.exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, ".");
RtlInitAnsiString(&Name, "NTDLL.DLL");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "F0_*.*");
RtlInitAnsiString(&Name, ".");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "..");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "SETUP.EXE");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "F0_001");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "*.TTF");
RtlInitAnsiString(&Name, ".");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "..");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "SETUP.INI");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "*");
RtlInitAnsiString(&Name, ".");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "..");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "SETUP.INI");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "\"ntoskrnl.exe");
RtlInitAnsiString(&Name, "ntoskrnl.exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "ntoskrnl\"exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "ntoskrn\".exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "ntoskrn\"\"exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "ntoskrnl.\"exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "ntoskrnl.exe\"");
RtlInitAnsiString(&Name, "ntoskrnl.exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "ntoskrnl.exe.");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "*.c.d");
RtlInitAnsiString(&Name, "a.b.c.d");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "*.?.c.d");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "*?");
RtlInitAnsiString(&Name, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "a");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "aa");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "aaa");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "?*?");
RtlInitAnsiString(&Name, "");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "a");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Name, "aa");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "aaa");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Name, "aaaa");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
/* Tests from #5923 */
RtlInitAnsiString(&Expression, "C:\\ReactOS\\**");
RtlInitAnsiString(&Name, "C:\\ReactOS\\dings.bmp");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "C:\\ReactOS\\***");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE");
RtlInitAnsiString(&Expression, "C:\\Windows\\*a*");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "C:\\ReactOS\\*.bmp");
RtlInitAnsiString(&Name, "C:\\Windows\\explorer.exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
RtlInitAnsiString(&Expression, "*.bmp;*.dib");
RtlInitAnsiString(&Name, "winhlp32.exe");
ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE");
}
/* PUBLIC FUNCTIONS ***********************************************************/
VOID
NtoskrnlFsRtlTest(HANDLE KeyHandle)
{
StartTest();
FsRtlIsNameInExpressionTest();
FsRtlIsDbcsInExpressionTest();
FinishTest(KeyHandle, L"FsRtlTest");
}
-168
View File
@@ -1,168 +0,0 @@
/*
* NTOSKRNL Io Regressions KM-Test
* ReactOS Kernel Mode Regression Testing framework
*
* Copyright 2006 Aleksey Bragin <[email protected]>
* Copyright 2008 Etersoft (Alexander Morozov)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntddk.h>
#include "kmtest.h"
#define NDEBUG
#include "debug.h"
/* PUBLIC FUNCTIONS ***********************************************************/
VOID NtoskrnlIoMdlTest(HANDLE KeyHandle)
{
PMDL Mdl;
PIRP Irp;
PVOID VirtualAddress;
ULONG MdlSize = 2*4096+184; // 2 pages and some random value
StartTest();
// Try to alloc 2Gb MDL
Mdl = IoAllocateMdl(NULL, 2048UL*0x100000, FALSE, FALSE, NULL);
ok(Mdl == NULL,
"IoAllocateMdl should fail allocation of 2Gb or more, but got Mdl=0x%X",
(UINT_PTR)Mdl);
if (Mdl)
IoFreeMdl(Mdl);
// Now create a valid MDL
VirtualAddress = ExAllocatePool(NonPagedPool, MdlSize);
Mdl = IoAllocateMdl(VirtualAddress, MdlSize, FALSE, FALSE, NULL);
ok(Mdl != NULL, "Mdl allocation failed");
// Check fields of the allocated struct
ok(Mdl->Next == NULL, "Mdl->Next should be NULL, but is 0x%X",
(UINT_PTR)Mdl->Next);
ok(Mdl->ByteCount == MdlSize,
"Mdl->ByteCount should be equal to MdlSize, but is 0x%X",
(UINT_PTR)Mdl->ByteCount);
// TODO: Check other fields of MDL struct
IoFreeMdl(Mdl);
// Allocate now with pointer to an Irp
Irp = IoAllocateIrp(1, FALSE);
ok(Irp != NULL, "IRP allocation failed");
Mdl = IoAllocateMdl(VirtualAddress, MdlSize, FALSE, FALSE, Irp);
ok(Mdl != NULL, "Mdl allocation failed");
ok(Irp->MdlAddress == Mdl, "Irp->MdlAddress should be 0x%X, but is 0x%X",
(UINT_PTR)Mdl, (UINT_PTR)Irp->MdlAddress);
IoFreeMdl(Mdl);
// TODO: Check a case when SecondaryBuffer == TRUE
IoFreeIrp(Irp);
ExFreePool(VirtualAddress);
FinishTest(KeyHandle, L"IoMdlTest");
}
VOID NtoskrnlIoIrpTest(HANDLE KeyHandle)
{
USHORT size;
IRP *iorp;
StartTest();
// 1st test
size = sizeof(IRP) + 5 * sizeof(IO_STACK_LOCATION);
iorp = ExAllocatePool(NonPagedPool, size);
if (NULL != iorp)
{
IoInitializeIrp(iorp, size, 5);
ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type);
ok(iorp->Size == size, "Irp size should be %d, but got %d\n",
iorp->Size, size);
ok(5 == iorp->StackCount, "Irp StackCount should be 5, but got %d\n",
iorp->StackCount);
ok(6 == iorp->CurrentLocation, "Irp CurrentLocation should be 6, but got %d\n",
iorp->CurrentLocation);
ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n");
ok ((PIO_STACK_LOCATION)(iorp + 1) + 5 ==
iorp->Tail.Overlay.CurrentStackLocation,
"CurrentStackLocation mismatch\n");
ExFreePool(iorp);
}
// 2nd test
size = sizeof(IRP) + 2 * sizeof(IO_STACK_LOCATION);
iorp = IoAllocateIrp(2, FALSE);
if (NULL != iorp)
{
ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type);
ok(iorp->Size >= size,
"Irp size should be more or equal to %d, but got %d\n",
iorp->Size, size);
ok(2 == iorp->StackCount, "Irp StackCount should be 2, but got %d\n",
iorp->StackCount);
ok(3 == iorp->CurrentLocation, "Irp CurrentLocation should be 3, but got %d\n",
iorp->CurrentLocation);
ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n");
ok ((PIO_STACK_LOCATION)(iorp + 1) + 2 ==
iorp->Tail.Overlay.CurrentStackLocation,
"CurrentStackLocation mismatch\n");
ok((IRP_ALLOCATED_FIXED_SIZE & iorp->AllocationFlags),
"IRP Allocation flags lack fixed size attribute\n");
ok(!(IRP_LOOKASIDE_ALLOCATION & iorp->AllocationFlags),
"IRP Allocation flags should not have lookaside allocation\n");
IoFreeIrp(iorp);
}
// 3rd test
size = sizeof(IRP) + 2 * sizeof(IO_STACK_LOCATION);
iorp = IoAllocateIrp(2, TRUE);
if (NULL != iorp)
{
ok(6 == iorp->Type, "Irp type should be 6, but got %d\n", iorp->Type);
ok(iorp->Size >= size,
"Irp size should be more or equal to %d, but got %d\n",
iorp->Size, size);
ok(2 == iorp->StackCount, "Irp StackCount should be 2, but got %d\n",
iorp->StackCount);
ok(3 == iorp->CurrentLocation, "Irp CurrentLocation should be 3, but got %d\n",
iorp->CurrentLocation);
ok(IsListEmpty(&iorp->ThreadListEntry), "IRP thread list is not empty\n");
ok ((PIO_STACK_LOCATION)(iorp + 1) + 2 ==
iorp->Tail.Overlay.CurrentStackLocation,
"CurrentStackLocation mismatch\n");
ok((IRP_ALLOCATED_FIXED_SIZE & iorp->AllocationFlags),
"IRP Allocation flags lack fixed size attribute\n");
ok((IRP_LOOKASIDE_ALLOCATION & iorp->AllocationFlags),
"IRP Allocation flags lack lookaside allocation\n");
IoFreeIrp(iorp);
}
FinishTest(KeyHandle, L"IoIrpTest");
}
-77
View File
@@ -1,77 +0,0 @@
/*
* NTOSKRNL Executive Regressions KM-Test
* ReactOS Kernel Mode Regression Testing framework
*
* Copyright 2006 Aleksey Bragin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntddk.h>
#include <ntifs.h>
#include <ndk/ntndk.h>
#include "kmtest.h"
#define NDEBUG
#include "debug.h"
/* PUBLIC FUNCTIONS ***********************************************************/
VOID
KeStallTest(HANDLE KeyHandle)
{
ULONG i;
LARGE_INTEGER TimeStart, TimeFinish;
StartTest();
DPRINT1("Waiting for 30 secs with 50us stalls...\n");
KeQuerySystemTime(&TimeStart);
for (i = 0; i < (30*1000*20); i++)
{
KeStallExecutionProcessor(50);
}
KeQuerySystemTime(&TimeFinish);
DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
DPRINT1("Waiting for 30 secs with 1000us stalls...\n");
KeQuerySystemTime(&TimeStart);
for (i = 0; i < (30*1000); i++)
{
KeStallExecutionProcessor(1000);
}
KeQuerySystemTime(&TimeFinish);
DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
DPRINT1("Waiting for 30 secs with 1us stalls...\n");
KeQuerySystemTime(&TimeStart);
for (i = 0; i < (30*1000*1000); i++)
{
KeStallExecutionProcessor(1);
}
KeQuerySystemTime(&TimeFinish);
DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 43
DPRINT1("Waiting for 30 secs with one huge stall...\n");
KeQuerySystemTime(&TimeStart);
KeStallExecutionProcessor(30*1000000);
KeQuerySystemTime(&TimeFinish);
DPRINT1("Time elapsed: %d secs\n", (TimeFinish.QuadPart - TimeStart.QuadPart) / 10000000); // 30
FinishTest(KeyHandle, L"KeStallmanExecutionTest");
}
-519
View File
@@ -1,519 +0,0 @@
/*
* NTOSKRNL Ob Regressions KM-Test
* ReactOS Kernel Mode Regression Testing framework
*
* Copyright 2006 Aleksey Bragin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntddk.h>
#include <ddk/ntifs.h>
#include "kmtest.h"
#define NDEBUG
#include "debug.h"
#include "ntndk.h"
// I ment to make this test scalable, but for now
// we work with two object types only
#define NUM_OBTYPES 2
typedef struct _MY_OBJECT1
{
ULONG Something1;
} MY_OBJECT1, *PMY_OBJECT1;
typedef struct _MY_OBJECT2
{
ULONG Something1;
ULONG SomeLong[10];
} MY_OBJECT2, *PMY_OBJECT2;
POBJECT_TYPE ObTypes[NUM_OBTYPES];
UNICODE_STRING ObTypeName[NUM_OBTYPES];
UNICODE_STRING ObName[NUM_OBTYPES];
OBJECT_TYPE_INITIALIZER ObTypeInitializer[NUM_OBTYPES];
UNICODE_STRING ObDirectoryName;
OBJECT_ATTRIBUTES ObDirectoryAttributes;
OBJECT_ATTRIBUTES ObAttributes[NUM_OBTYPES];
PVOID ObBody[NUM_OBTYPES];
PMY_OBJECT1 ObObject1;
PMY_OBJECT2 ObObject2;
HANDLE ObHandle1[NUM_OBTYPES];
HANDLE ObHandle2[NUM_OBTYPES];
HANDLE DirectoryHandle;
USHORT DumpCount, OpenCount, CloseCount, DeleteCount,
ParseCount, OkayToCloseCount, QueryNameCount;
/* PRIVATE FUNCTIONS **********************************************************/
VOID
NTAPI
DumpProc(IN PVOID Object,
IN POB_DUMP_CONTROL DumpControl)
{
DbgPrint("DumpProc() called\n");
DumpCount++;
}
// Tested in Win2k3
VOID
NTAPI
OpenProc(IN OB_OPEN_REASON OpenReason,
IN PEPROCESS Process,
IN PVOID Object,
IN ACCESS_MASK GrantedAccess,
IN ULONG HandleCount)
{
DbgPrint("OpenProc() 0x%p, OpenReason %d, HC %d, AM 0x%X\n",
Object, OpenReason, HandleCount, GrantedAccess);
OpenCount++;
}
// Tested in Win2k3
VOID
NTAPI
CloseProc(IN PEPROCESS Process,
IN PVOID Object,
IN ACCESS_MASK GrantedAccess,
IN ULONG ProcessHandleCount,
IN ULONG SystemHandleCount)
{
DbgPrint("CloseProc() 0x%p, PHC %d, SHC %d, AM 0x%X\n", Object,
ProcessHandleCount, SystemHandleCount, GrantedAccess);
CloseCount++;
}
// Tested in Win2k3
VOID
NTAPI
DeleteProc(IN PVOID Object)
{
DbgPrint("DeleteProc() 0x%p\n", Object);
DeleteCount++;
}
NTSTATUS
NTAPI
ParseProc(IN PVOID ParseObject,
IN PVOID ObjectType,
IN OUT PACCESS_STATE AccessState,
IN KPROCESSOR_MODE AccessMode,
IN ULONG Attributes,
IN OUT PUNICODE_STRING CompleteName,
IN OUT PUNICODE_STRING RemainingName,
IN OUT PVOID Context OPTIONAL,
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
OUT PVOID *Object)
{
DbgPrint("ParseProc() called\n");
*Object = NULL;
ParseCount++;
return STATUS_OBJECT_NAME_NOT_FOUND;//STATUS_SUCCESS;
}
// Tested in Win2k3
NTSTATUS
NTAPI
OkayToCloseProc(IN PEPROCESS Process OPTIONAL,
IN PVOID Object,
IN HANDLE Handle,
IN KPROCESSOR_MODE AccessMode)
{
DbgPrint("OkayToCloseProc() 0x%p, H 0x%p, AM 0x%X\n", Object, Handle,
AccessMode);
OkayToCloseCount++;
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
QueryNameProc(IN PVOID Object,
IN BOOLEAN HasObjectName,
OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
IN ULONG Length,
OUT PULONG ReturnLength,
IN KPROCESSOR_MODE AccessMode)
{
DbgPrint("QueryNameProc() 0x%p, HON %d, Len %d, AM 0x%X\n",
Object, HasObjectName, Length, AccessMode);
QueryNameCount++;
ObjectNameInfo = NULL;
ReturnLength = 0;
return STATUS_OBJECT_NAME_NOT_FOUND;
}
VOID
ObtCreateObjectTypes()
{
USHORT i;
NTSTATUS Status;
WCHAR Name[15];
for (i=0; i<NUM_OBTYPES; i++)
{
// Prepare object type name
// TODO: Generate type names and don't use this unprofessional,
swprintf(Name, L"MyObjectType%lx", i);
RtlInitUnicodeString(&ObTypeName[i], Name);
// Prepare initializer
RtlZeroMemory(&ObTypeInitializer[i], sizeof(ObTypeInitializer[i]));
ObTypeInitializer[i].Length = sizeof(ObTypeInitializer[i]);
ObTypeInitializer[i].PoolType = NonPagedPool;
ObTypeInitializer[i].MaintainHandleCount = TRUE;
ObTypeInitializer[i].ValidAccessMask = OBJECT_TYPE_ALL_ACCESS;
// Test for invalid parameter
// FIXME: Make it more exact, to see which params Win2k3 checks
// existence of
Status = ObCreateObjectType(&ObTypeName[i], &ObTypeInitializer[i],
(PSECURITY_DESCRIPTOR)NULL, &ObTypes[i]);
ok(Status == STATUS_INVALID_PARAMETER,
"ObCreateObjectType returned 0x%lX", Status);
// Object procedures
ObTypeInitializer[i].CloseProcedure = (OB_CLOSE_METHOD)CloseProc;
ObTypeInitializer[i].DeleteProcedure = (OB_DELETE_METHOD)DeleteProc;
ObTypeInitializer[i].DumpProcedure = (OB_DUMP_METHOD)DumpProc;
ObTypeInitializer[i].OpenProcedure = (OB_OPEN_METHOD)OpenProc;
ObTypeInitializer[i].ParseProcedure = (OB_PARSE_METHOD)ParseProc;
//ObTypeInitializer[i].OkayToCloseProcedure =
// (OB_OKAYTOCLOSE_METHOD)OkayToCloseProc;
//ObTypeInitializer[i].QueryNameProcedure =
// (OB_QUERYNAME_METHOD)QueryNameProc;
//ObTypeInitializer[i].SecurityProcedure =
// (OB_SECURITY_METHOD)SecurityProc;
Status = ObCreateObjectType(&ObTypeName[i], &ObTypeInitializer[i],
(PSECURITY_DESCRIPTOR)NULL, &ObTypes[i]);
ok(Status == STATUS_SUCCESS,
"Failed to create object type with status=0x%lX", Status);
}
}
VOID
ObtCreateDirectory()
{
NTSTATUS Status;
// Directory will have permanent and case insensitive flags
RtlInitUnicodeString(&ObDirectoryName, L"\\ObtDirectory");
InitializeObjectAttributes(&ObDirectoryAttributes, &ObDirectoryName,
OBJ_PERMANENT | OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ZwCreateDirectoryObject(&DirectoryHandle, 0, &ObDirectoryAttributes);
ok(Status == STATUS_SUCCESS,
"Failed to create directory object with status=0x%lX", Status);
}
VOID
ObtCreateObjects()
{
PVOID ObBody1[2];
NTSTATUS Status;
USHORT OpenSave, CloseSave, DeleteSave, ParseSave,
OkayToCloseSave, QueryNameSave;
// Create two objects
RtlInitUnicodeString(&ObName[0], L"\\ObtDirectory\\MyObject1");
InitializeObjectAttributes(&ObAttributes[0], &ObName[0],
OBJ_CASE_INSENSITIVE, NULL, NULL);
RtlInitUnicodeString(&ObName[1], L"\\ObtDirectory\\MyObject2");
InitializeObjectAttributes(&ObAttributes[1], &ObName[1],
OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ObCreateObject(KernelMode, ObTypes[0], &ObAttributes[0],
KernelMode, NULL, (ULONG)sizeof(MY_OBJECT1), 0L, 0L,
(PVOID *)&ObBody[0]);
ok(Status == STATUS_SUCCESS,
"Failed to create object with status=0x%lX", Status);
Status = ObCreateObject(KernelMode, ObTypes[1], &ObAttributes[1],
KernelMode, NULL, (ULONG)sizeof(MY_OBJECT2), 0L, 0L,
(PVOID *)&ObBody[1]);
ok(Status == STATUS_SUCCESS,
"Failed to create object with status=0x%lX", Status);
// save counters
OpenSave=OpenCount; CloseSave=CloseCount; DeleteSave=DeleteCount;
ParseSave=ParseCount; OkayToCloseSave=OkayToCloseCount;
QueryNameSave=QueryNameCount;
// Insert them
Status = ObInsertObject(ObBody[0], NULL, STANDARD_RIGHTS_ALL, 0,
&ObBody[0], &ObHandle1[0]);
ok(Status == STATUS_SUCCESS,
"Failed to insert object 0 with status=0x%lX", Status);
ok(ObBody[0] != NULL, "Object body = NULL");
ok(ObHandle1[0] != NULL, "Handle = NULL");
// check counters
ok(OpenSave+1 == OpenCount, "Open method calls mismatch\n");
ok(CloseSave == CloseCount, "Excessive Close method call\n");
ok(DeleteSave == DeleteCount, "Excessive Delete method call\n");
ok(ParseSave == ParseCount, "Excessive Parse method call\n");
// save counters
OpenSave=OpenCount; CloseSave=CloseCount; DeleteSave=DeleteCount;
ParseSave=ParseCount; OkayToCloseSave=OkayToCloseCount;
QueryNameSave=QueryNameCount;
Status = ObInsertObject(ObBody[1], NULL, GENERIC_ALL, 0,
&ObBody[1], &ObHandle1[1]);
ok(Status == STATUS_SUCCESS,
"Failed to insert object 1 with status=0x%lX", Status);
ok(ObBody[1] != NULL, "Object body = NULL");
ok(ObHandle1[1] != NULL, "Handle = NULL");
// check counters
ok(OpenSave+1 == OpenCount, "Open method calls mismatch\n");
ok(CloseSave == CloseCount, "Excessive Close method call\n");
ok(DeleteSave == DeleteCount, "Excessive Delete method call\n");
ok(ParseSave == ParseCount, "Excessive Parse method call\n");
// save counters
OpenSave=OpenCount; CloseSave=CloseCount; DeleteSave=DeleteCount;
ParseSave=ParseCount; OkayToCloseSave=OkayToCloseCount;
QueryNameSave=QueryNameCount;
// Now create an object of type 0, of the same name and expect it to fail
// inserting, but success creation
RtlInitUnicodeString(&ObName[0], L"\\ObtDirectory\\MyObject1");
InitializeObjectAttributes(&ObAttributes[0], &ObName[0], OBJ_OPENIF,
NULL, NULL);
Status = ObCreateObject(KernelMode, ObTypes[0], &ObAttributes[0], KernelMode,
NULL, (ULONG)sizeof(MY_OBJECT1), 0L, 0L, (PVOID *)&ObBody1[0]);
ok(Status == STATUS_SUCCESS,
"Failed to create object with status=0x%lX", Status);
// check counters
ok(OpenSave == OpenCount, "Excessive Open method call\n");
ok(CloseSave == CloseCount, "Excessive Close method call\n");
ok(DeleteSave == DeleteCount, "Excessive Delete method call\n");
ok(ParseSave == ParseCount, "Excessive Parse method call\n");
Status = ObInsertObject(ObBody1[0], NULL, GENERIC_ALL, 0,
&ObBody1[1], &ObHandle2[0]);
ok(Status == STATUS_OBJECT_NAME_EXISTS,
"Object insertion should have failed, but got 0x%lX", Status);
ok(ObBody[0] == ObBody1[1],
"Object bodies doesn't match, 0x%p != 0x%p", ObBody[0], ObBody1[1]);
ok(ObHandle2[0] != NULL, "Bad handle returned 0x%lX", (ULONG_PTR)ObHandle2[0]);
DPRINT1("%d %d %d %d %d %d %d\n", DumpCount, OpenCount, // deletecount+1
CloseCount, DeleteCount, ParseCount, OkayToCloseCount, QueryNameCount);
// check counters and then save
ok(OpenSave+1 == OpenCount, "Excessive Open method call\n");
ok(CloseSave == CloseCount, "Excessive Close method call\n");
ok(DeleteSave+1 == DeleteCount, "Delete method call mismatch\n");
ok(ParseSave == ParseCount, "Excessive Parse method call\n");
OpenSave=OpenCount; CloseSave=CloseCount; DeleteSave=DeleteCount;
ParseSave=ParseCount; OkayToCloseSave=OkayToCloseCount;
QueryNameSave=QueryNameCount;
// Close its handle
Status = ZwClose(ObHandle2[0]);
ok(Status == STATUS_SUCCESS,
"Failed to close handle status=0x%lX", Status);
// check counters and then save
ok(OpenSave == OpenCount, "Excessive Open method call\n");
ok(CloseSave+1 == CloseCount, "Close method call mismatch\n");
ok(DeleteSave == DeleteCount, "Excessive Delete method call\n");
ok(ParseSave == ParseCount, "Excessive Parse method call\n");
OpenSave=OpenCount; CloseSave=CloseCount; DeleteSave=DeleteCount;
ParseSave=ParseCount; OkayToCloseSave=OkayToCloseCount;
QueryNameSave=QueryNameCount;
// Object referenced 2 times:
// 1) ObInsertObject
// 2) AdditionalReferences
ObDereferenceObject(ObBody1[1]);
//DPRINT1("%d %d %d %d %d %d %d\n", DumpCount, OpenCount, // no change
// CloseCount, DeleteCount, ParseCount, OkayToCloseCount, QueryNameCount);
ok(OpenSave == OpenCount, "Open method call mismatch\n");
ok(CloseSave == CloseCount, "Close method call mismatch\n");
ok(DeleteSave == DeleteCount, "Delete method call mismatch\n");
ok(ParseSave == ParseCount, "Parse method call mismatch\n");
}
VOID
ObtClose()
{
PVOID DirObject;
NTSTATUS Status;
//PVOID TypeObject;
USHORT i;
//UNICODE_STRING ObPathName[NUM_OBTYPES];
// Close what we have opened and free what we allocated
ZwClose(ObHandle1[0]);
ZwClose(ObHandle1[1]);
ZwClose(ObHandle2[0]);
ZwClose(ObHandle2[1]);
// Now we have to get rid of a directory object
// Since it is permanent, we have to firstly make it temporary
// and only then kill
// (this procedure is described in DDK)
Status = ObReferenceObjectByHandle(DirectoryHandle, 0L, NULL,
KernelMode, &DirObject, NULL);
ok(Status == STATUS_SUCCESS,
"Failed to reference object by handle with status=0x%lX", Status);
// Dereference 2 times - first for just previous referencing
// and 2nd time for creation of permanent object itself
ObDereferenceObject(DirObject);
ObDereferenceObject(DirObject);
Status = ZwMakeTemporaryObject(DirectoryHandle);
ok(Status == STATUS_SUCCESS,
"Failed to make temp object with status=0x%lX", Status);
// Close the handle now and we are done
Status = ZwClose(DirectoryHandle);
ok(Status == STATUS_SUCCESS,
"Failed to close handle with status=0x%lX", Status);
// Now delete the last piece - object types
// In fact, it's weird to get rid of object types, especially the way,
// how it's done in the commented section below
for (i=0; i<NUM_OBTYPES; i++)
ObDereferenceObject(ObTypes[i]);
/*
RtlInitUnicodeString(&ObPathName[0], L"\\ObjectTypes\\MyObjectType1");
RtlInitUnicodeString(&ObPathName[1], L"\\ObjectTypes\\MyObjectType2");
for (i=0; i<NUM_OBTYPES; i++)
{
Status = ObReferenceObjectByName(&ObPathName[i],
OBJ_CASE_INSENSITIVE, NULL, 0L, NULL, KernelMode, NULL,
&TypeObject);
ObDereferenceObject(TypeObject);
ObDereferenceObject(TypeObject);
DPRINT("Reference Name %S = %p, ObTypes[%d] = %p\n",
ObPathName[i], TypeObject, i, ObTypes[i]);
}
*/
}
VOID
ObtReferenceTests()
{
USHORT i;
NTSTATUS Status;
UNICODE_STRING ObPathName[NUM_OBTYPES];
// Reference them by handle
for (i=0; i<NUM_OBTYPES; i++)
{
Status = ObReferenceObjectByHandle(ObHandle1[i], 0L, ObTypes[i],
KernelMode, &ObBody[i], NULL);
ok(Status == STATUS_SUCCESS,
"Failed to reference object by handle, status=0x%lX", Status);
DPRINT("Ref by handle %lx = %p\n", ObHandle1[i], ObBody[i]);
}
// Reference them by pointer
for (i=0; i<NUM_OBTYPES; i++)
{
Status = ObReferenceObjectByPointer(ObBody[i], 0L, ObTypes[i], KernelMode);
ok(Status == STATUS_SUCCESS,
"Failed to reference object by pointer, status=0x%lX", Status);
}
// Reference them by name
RtlInitUnicodeString(&ObPathName[0], L"\\ObtDirectory\\MyObject1");
RtlInitUnicodeString(&ObPathName[1], L"\\ObtDirectory\\MyObject2");
for (i=0; i<NUM_OBTYPES; i++)
{
Status = ObReferenceObjectByName(&ObPathName[i],
OBJ_CASE_INSENSITIVE, NULL, 0L, ObTypes[i], KernelMode, NULL,
&ObBody[0]);
DPRINT("Ref by name %wZ = %p\n", &ObPathName[i], ObBody[i]);
}
// Dereference now all of them
// For ObInsertObject, AdditionalReference
ObDereferenceObject(ObBody[0]);
ObDereferenceObject(ObBody[1]);
// For ByHandle
ObDereferenceObject(ObBody[0]);
ObDereferenceObject(ObBody[1]);
// For ByPointer
ObDereferenceObject(ObBody[0]);
ObDereferenceObject(ObBody[1]);
// For ByName
ObDereferenceObject(ObBody[0]);
ObDereferenceObject(ObBody[1]);
}
/* PUBLIC FUNCTIONS ***********************************************************/
VOID
NtoskrnlObTest(HANDLE KeyHandle)
{
StartTest();
DumpCount = 0; OpenCount = 0; CloseCount = 0;
DeleteCount = 0; ParseCount = 0;
// Create object-types to use in tests
ObtCreateObjectTypes();
DPRINT("ObtCreateObjectTypes() done\n");
// Create Directory
ObtCreateDirectory();
DPRINT("ObtCreateDirectory() done\n");
// Create and insert objects
ObtCreateObjects();
DPRINT("ObtCreateObjects() done\n");
// Reference them in a variety of ways
//ObtReferenceTests();
// Clean up
// FIXME: Disable to see results of creating objects in usermode.
// Also it has problems with object types removal
ObtClose();
DPRINT("Cleanup done\n");
FinishTest(KeyHandle, L"ObMgrTest");
}
-178
View File
@@ -1,178 +0,0 @@
/*
* NTOSKRNL Pools test routines KM-Test
* ReactOS Kernel Mode Regression Testing framework
*
* Copyright 2008 Aleksey Bragin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <ddk/ntddk.h>
#include <ntifs.h>
#include <ndk/ntndk.h>
/* SEH support with PSEH */
#include <pseh/pseh2.h>
#include "kmtest.h"
#define NDEBUG
#include "debug.h"
#define TAG_POOLTEST 'tstP'
/* PUBLIC FUNCTIONS ***********************************************************/
VOID
PoolsTest(HANDLE KeyHandle)
{
PVOID Ptr;
ULONG AllocSize, i, AllocNumber;
PVOID *Allocs;
StartTest();
// Stress-test nonpaged pool
for (i=1; i<10000; i++)
{
// make up some increasing, a bit irregular size
AllocSize = i*10;
if (i % 10)
AllocSize++;
if (i % 25)
AllocSize += 13;
// start with non-paged pool
Ptr = ExAllocatePoolWithTag(NonPagedPool, AllocSize, TAG_POOLTEST);
// it may fail due to no-memory condition
if (!Ptr) break;
// try to fully fill it
RtlFillMemory(Ptr, AllocSize, 0xAB);
// free it
ExFreePoolWithTag(Ptr, TAG_POOLTEST);
}
// now paged one
for (i=1; i<10000; i++)
{
// make up some increasing, a bit irregular size
AllocSize = i*50;
if (i % 10)
AllocSize++;
if (i % 25)
AllocSize += 13;
// start with non-paged pool
Ptr = ExAllocatePoolWithTag(PagedPool, AllocSize, TAG_POOLTEST);
// it may fail due to no-memory condition
if (!Ptr) break;
// try to fully fill it
RtlFillMemory(Ptr, AllocSize, 0xAB);
// free it
ExFreePoolWithTag(Ptr, TAG_POOLTEST);
}
// test super-big allocations
/*AllocSize = 2UL * 1024 * 1024 * 1024;
Ptr = ExAllocatePoolWithTag(NonPagedPool, AllocSize, TAG_POOLTEST);
ok(Ptr == NULL, "Allocating 2Gb of nonpaged pool should fail\n");
Ptr = ExAllocatePoolWithTag(PagedPool, AllocSize, TAG_POOLTEST);
ok(Ptr == NULL, "Allocating 2Gb of paged pool should fail\n");*/
// now test allocating lots of small/medium blocks
AllocNumber = 100000;
Allocs = ExAllocatePoolWithTag(PagedPool, sizeof(Allocs) * AllocNumber, TAG_POOLTEST);
// alloc blocks
for (i=0; i<AllocNumber; i++)
{
AllocSize = 42;
Allocs[i] = ExAllocatePoolWithTag(NonPagedPool, AllocSize, TAG_POOLTEST);
}
// now free them
for (i=0; i<AllocNumber; i++)
{
ExFreePoolWithTag(Allocs[i], TAG_POOLTEST);
}
ExFreePoolWithTag(Allocs, TAG_POOLTEST);
FinishTest(KeyHandle, L"MmPoolAllocTest");
}
VOID
PoolsCorruption(HANDLE KeyHandle)
{
PULONG Ptr, TestPtr;
ULONG AllocSize;
NTSTATUS Status = STATUS_SUCCESS;
StartTest();
// start with non-paged pool
AllocSize = 4096 + 0x10;
Ptr = ExAllocatePoolWithTag(NonPagedPool, AllocSize, TAG_POOLTEST);
// touch all bytes, it shouldn't cause an exception
RtlZeroMemory(Ptr, AllocSize);
// test buffer overrun, right after our allocation ends
_SEH2_TRY
{
TestPtr = (PULONG)((PUCHAR)Ptr + AllocSize);
//Ptr[4] = 0xd33dbeef;
*TestPtr = 0xd33dbeef;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the status */
Status = _SEH2_GetExceptionCode();
} _SEH2_END;
ok(Status == STATUS_ACCESS_VIOLATION, "Exception should occur, but got Status 0x%08lX\n", Status);
// test overrun in a distant byte range, but within 4096KB
_SEH2_TRY
{
Ptr[2020] = 0xdeadb33f;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the status */
Status = _SEH2_GetExceptionCode();
} _SEH2_END;
ok(Status == STATUS_ACCESS_VIOLATION, "Exception should occur, but got Status 0x%08lX\n", Status);
// free the pool
ExFreePoolWithTag(Ptr, TAG_POOLTEST);
FinishTest(KeyHandle, L"MmPoolCorruptionTest");
}
-219
View File
@@ -1,219 +0,0 @@
/*
* Driver Regression Tests
*
* Copyright 2009 Michael Martin <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include "kmtest.h"
/*
Adds a service registry entry for a driver
The driver must reside in the same path as this loaded driver
The caller is resposible for releasing memory
*/
PWCHAR CreateLowerDeviceRegistryKey(PUNICODE_STRING RegistryPath, PWCHAR NewDriver)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING Name;
UNICODE_STRING Value;
UNICODE_STRING NewDriverRegPath;
PKEY_VALUE_PARTIAL_INFORMATION ValuePartialInfo = NULL;
HANDLE ServiceKey;
NTSTATUS Status;
ULONG Disposition;
ULONG ServiceDWordValue;
ULONG ResultLength = 0;
ULONG Length = 0;
PWCHAR ReturnPath = NULL;
/* Now lets find out where we were loaded from by using registry */
InitializeObjectAttributes(&ObjectAttributes, RegistryPath, OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ZwOpenKey(&ServiceKey, KEY_READ, &ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwOpenKey () failed (Status %x)\n", Status);
return NULL;
}
RtlInitUnicodeString(&Name, L"ImagePath");
/* First query how much memory we need */
Status = ZwQueryValueKey(ServiceKey, &Name, KeyValuePartialInformation, 0, 0, &ResultLength);
ResultLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
ValuePartialInfo = ExAllocatePool(PagedPool, ResultLength);
if (!ValuePartialInfo)
{
DbgPrint("Out of memory!\n");
goto cleanup;
}
Length = ResultLength;
Status = ZwQueryValueKey(ServiceKey, &Name, KeyValuePartialInformation, (PVOID)ValuePartialInfo, Length, &ResultLength);
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwQueryValueKey() failed (Status %lx)\n", Status);
goto cleanup;
}
/* Remove the current driver name from the string */
/* FIXME: Dont use hard coded driver name, determine it from the string returned from the above Query */
Length = (wcslen((PWCHAR)ValuePartialInfo->Data) * 2) - (wcslen(L"kmtest.sys") * 2);
RtlZeroMemory((PVOID)((ULONG_PTR)ValuePartialInfo->Data + Length),
wcslen(L"drvtests.sys") * 2);
ZwClose(ServiceKey);
/* Now add a registry entry for the driver */
NewDriverRegPath.Length = 0;
NewDriverRegPath.MaximumLength = (wcslen(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\") +
wcslen(NewDriver) + 1) * sizeof(WCHAR);
NewDriverRegPath.Buffer = ExAllocatePool(PagedPool, NewDriverRegPath.MaximumLength);
if (!NewDriverRegPath.Buffer)
{
DbgPrint("Out of memory!\n");
ExFreePool(NewDriverRegPath.Buffer);
goto cleanup;
}
RtlAppendUnicodeToString(&NewDriverRegPath, L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\");
RtlAppendUnicodeToString(&NewDriverRegPath, NewDriver);
InitializeObjectAttributes(&ObjectAttributes,
&NewDriverRegPath,
OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
0,
NULL);
Status = ZwCreateKey(&ServiceKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE,
&Disposition);
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwCreateKey() failed (Status %lx)\n", Status);
ExFreePool(NewDriverRegPath.Buffer);
goto cleanup;
}
ReturnPath = NewDriverRegPath.Buffer;
RtlInitUnicodeString(&Name, L"ImagePath");
Value.Length = 0;
Value.MaximumLength = (wcslen((PWCHAR)ValuePartialInfo->Data) +
wcslen(NewDriver) + 5) * sizeof(WCHAR);
Value.Buffer = ExAllocatePool(PagedPool, Value.MaximumLength);
if (!Value.Buffer)
{
DbgPrint("Out of memory!\n");
ExFreePool(Value.Buffer);
goto cleanup;
}
RtlAppendUnicodeToString(&Value, (PWCHAR)ValuePartialInfo->Data);
RtlAppendUnicodeToString(&Value, NewDriver);
RtlAppendUnicodeToString(&Value, L".sys");
Status = ZwSetValueKey(ServiceKey,
&Name,
0,
REG_SZ,
Value.Buffer,
(wcslen(Value.Buffer)+1) * sizeof(WCHAR));
ExFreePool(Value.Buffer);
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwCreateKey() failed (Status %lx)\n", Status);
goto cleanup;
}
RtlInitUnicodeString(&Name, L"DisplayName");
RtlInitUnicodeString(&Value, NewDriver);
Status = ZwSetValueKey(ServiceKey,
&Name,
0,
REG_SZ,
Value.Buffer,
(wcslen(Value.Buffer)+1) * sizeof(WCHAR));
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwCreateKey() failed (Status %lx)\n", Status);
goto cleanup;
}
RtlInitUnicodeString(&Name, L"ErrorControl");
ServiceDWordValue = 0;
Status = ZwSetValueKey(ServiceKey,
&Name,
0,
REG_DWORD,
&ServiceDWordValue,
sizeof(ULONG));
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwCreateKey() failed (Status %lx)\n", Status);
goto cleanup;
}
RtlInitUnicodeString(&Name, L"Start");
ServiceDWordValue = 3;
Status = ZwSetValueKey(ServiceKey,
&Name,
0,
REG_DWORD,
&ServiceDWordValue,
sizeof(ULONG));
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwCreateKey() failed (Status %lx)\n", Status);
goto cleanup;
}
RtlInitUnicodeString(&Name, L"Type");
ServiceDWordValue = 0;
Status = ZwSetValueKey(ServiceKey,
&Name,
0,
REG_DWORD,
&ServiceDWordValue,
sizeof(ULONG));
if (!NT_SUCCESS(Status))
{
DbgPrint("ZwCreateKey() failed (Status %lx)\n", Status);
goto cleanup;
}
cleanup:
ZwClose(ServiceKey);
if (ValuePartialInfo) ExFreePool(ValuePartialInfo);
return ReturnPath;
}
-11
View File
@@ -1,11 +0,0 @@
#add_subdirectory(cmd)
#add_subdirectory(DriverLoading)
#add_subdirectory(kernel32)
add_subdirectory(kmtloader)
#add_subdirectory(loadlib)
#add_subdirectory(msvcrt)
#add_subdirectory(rpcrt4)
#add_subdirectory(smss)
#add_subdirectory(user32)
#add_subdirectory(win32k)
-4
View File
@@ -1,4 +0,0 @@
add_executable(kmtloader kmtloader.c)
set_module_type(kmtloader win32cui)
add_importlibs(kmtloader msvcrt kernel32 advapi32)
add_cd_file(TARGET kmtloader DESTINATION reactos/bin FOR all)
-90
View File
@@ -1,90 +0,0 @@
/*
* Kernel-Mode Tests Loader (based on PnP Test Driver Loader by Filip Navara)
*
* Copyright 2004 Filip Navara <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB.
* If not, write to the Free Software Foundation,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* INCLUDES *******************************************************************/
#include <windows.h>
#include <stdio.h>
/* PUBLIC FUNCTIONS ***********************************************************/
int main()
{
SC_HANDLE schSCManager;
SC_HANDLE schService;
PWCHAR DriverName = L"KMTEST";
WCHAR ServiceExe[MAX_PATH];
printf("Kernel Mode Tests loader\n\n");
GetCurrentDirectoryW(MAX_PATH, ServiceExe);
wcscat(ServiceExe, L"\\kmtest.sys");
printf("Opening SC Manager...\n");
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (schSCManager == NULL)
{
DWORD Err = GetLastError();
printf("OpenSCManager failed with error 0x%lx\n", Err);
return 0;
}
printf("Creating service...\n");
schService = CreateServiceW(
schSCManager,
DriverName,
DriverName,
SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
ServiceExe,
NULL,
NULL,
NULL,
NULL,
NULL);
if (schService == NULL)
{
printf("Opening service...\n");
schService = OpenServiceW(schSCManager, DriverName, SERVICE_ALL_ACCESS);
}
if (schService == NULL)
{
DWORD Err = GetLastError();
printf("Create/OpenService failed with error 0x%lx\n", Err);
CloseServiceHandle(schSCManager);
return 0;
}
//for (;;) ;
printf("Starting service...\n");
StartService(schService, 0, NULL);
printf("Cleaning up and exiting\n");
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
return 0;
}
-4
View File
@@ -1,4 +0,0 @@
<module name="kmtloader" type="win32cui" installbase="system32" installname="kmtloader.exe">
<library>advapi32</library>
<file>kmtloader.c</file>
</module>
-3
View File
@@ -4,9 +4,6 @@
<directory name="kernel32">
<xi:include href="kernel32/directory.rbuild" />
</directory>
<directory name="kmtloader">
<xi:include href="kmtloader/kmtloader.rbuild" />
</directory>
<directory name="smss">
<xi:include href="smss/smss.rbuild" />
</directory>