Пример #1
0
static
VOID
TestVolumeInfo(
    IN HANDLE ServerHandle)
{
    NTSTATUS Status;
    IO_STATUS_BLOCK IoStatusBlock;
    FILE_FS_SIZE_INFORMATION FileFsSizeInfo;
    FILE_FS_DEVICE_INFORMATION FileFsDeviceInfo;
    FILE_FS_FULL_SIZE_INFORMATION FileFsFullSizeInfo;

    struct {
        FILE_FS_VOLUME_INFORMATION;
        WCHAR PartialName[10];
    } VolumeInfo;

    struct {
        FILE_FS_ATTRIBUTE_INFORMATION;
        WCHAR PartialName[6];
    } AttributeInfo;

    RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &VolumeInfo,
                                          sizeof(VolumeInfo),
                                          FileFsVolumeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
    ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
    ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
    ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
    ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
    ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedPipe", 18), 18);
    ok_eq_wchar(VolumeInfo.VolumeLabel[9], 0xFFFF);
    ok_eq_ulong(IoStatusBlock.Information, (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + 9 * sizeof(WCHAR)));

    RtlFillMemory(&VolumeInfo, sizeof(VolumeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &VolumeInfo,
                                          sizeof(FILE_FS_VOLUME_INFORMATION) + 2 * sizeof(WCHAR),
                                          FileFsVolumeInformation);
    ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
    ok_eq_hex(IoStatusBlock.Status, STATUS_BUFFER_OVERFLOW);
    ok_eq_long(VolumeInfo.VolumeCreationTime.LowPart, 0);
    ok_eq_long(VolumeInfo.VolumeCreationTime.HighPart, 0);
    ok_eq_ulong(VolumeInfo.VolumeSerialNumber, 0);
    ok_bool_false(VolumeInfo.SupportsObjects, "VolumeInfo.SupportsObjects");
    ok_eq_ulong(VolumeInfo.VolumeLabelLength, 18);
    ok_eq_size(RtlCompareMemory(VolumeInfo.VolumeLabel, L"NamedP", 10), 10);
    ok_eq_wchar(VolumeInfo.VolumeLabel[5], 0xFFFF);
    ok_eq_ulong(IoStatusBlock.Information, (FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + 5 * sizeof(WCHAR)));

    RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &FileFsSizeInfo,
                                          sizeof(FileFsSizeInfo),
                                          FileFsSizeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
    ok_eq_longlong(FileFsSizeInfo.AvailableAllocationUnits.QuadPart, 0);
    ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
    ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
    ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));

    RtlFillMemory(&FileFsSizeInfo, sizeof(FileFsSizeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &FileFsSizeInfo,
                                          sizeof(FileFsSizeInfo) - 4,
                                          FileFsSizeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_longlong(FileFsSizeInfo.TotalAllocationUnits.QuadPart, 0);
    ok_eq_longlong(FileFsSizeInfo.AvailableAllocationUnits.QuadPart, 0);
    ok_eq_ulong(FileFsSizeInfo.SectorsPerAllocationUnit, 1);
    ok_eq_ulong(FileFsSizeInfo.BytesPerSector, 1);
    ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsSizeInfo));

    RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &FileFsDeviceInfo,
                                          sizeof(FileFsDeviceInfo),
                                          FileFsDeviceInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
    ok_eq_ulong(FileFsDeviceInfo.DeviceType, FILE_DEVICE_NAMED_PIPE);
    ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));

    RtlFillMemory(&FileFsDeviceInfo, sizeof(FileFsDeviceInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &FileFsDeviceInfo,
                                          sizeof(FileFsDeviceInfo) - 4,
                                          FileFsDeviceInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_ulong(FileFsDeviceInfo.Characteristics, 0);
    ok_eq_ulong(FileFsDeviceInfo.DeviceType, FILE_DEVICE_NAMED_PIPE);
    ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsDeviceInfo));

    RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &AttributeInfo,
                                          sizeof(AttributeInfo),
                                          FileFsAttributeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
    ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
    ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
    ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
    ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
    ok_eq_ulong(IoStatusBlock.Information, 20);

    RtlFillMemory(&AttributeInfo, sizeof(AttributeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &AttributeInfo,
                                          sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 2 * sizeof(WCHAR),
                                          FileFsAttributeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_ulong(AttributeInfo.FileSystemAttributes, FILE_CASE_PRESERVED_NAMES);
    ok_eq_long(AttributeInfo.MaximumComponentNameLength, 0xFFFFFFFF);
    ok_eq_ulong(AttributeInfo.FileSystemNameLength, 8);
    ok_eq_size(RtlCompareMemory(AttributeInfo.FileSystemName, L"NPFS", 8), 8);
    ok_eq_wchar(AttributeInfo.FileSystemName[4], 0xFFFF);
    ok_eq_ulong(IoStatusBlock.Information, 20);

    RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &FileFsFullSizeInfo,
                                          sizeof(FileFsFullSizeInfo),
                                          FileFsFullSizeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
    ok_eq_longlong(FileFsFullSizeInfo.CallerAvailableAllocationUnits.QuadPart, 0);
    ok_eq_longlong(FileFsFullSizeInfo.ActualAvailableAllocationUnits.QuadPart, 0);
    ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
    ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
    ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));

    RtlFillMemory(&FileFsFullSizeInfo, sizeof(FileFsFullSizeInfo), 0xFF);
    Status = ZwQueryVolumeInformationFile(ServerHandle,
                                          &IoStatusBlock,
                                          &FileFsFullSizeInfo,
                                          sizeof(FileFsFullSizeInfo) - 4,
                                          FileFsFullSizeInformation);
    ok_eq_hex(Status, STATUS_SUCCESS);
    ok_eq_hex(IoStatusBlock.Status, STATUS_SUCCESS);
    ok_eq_longlong(FileFsFullSizeInfo.TotalAllocationUnits.QuadPart, 0);
    ok_eq_longlong(FileFsFullSizeInfo.CallerAvailableAllocationUnits.QuadPart, 0);
    ok_eq_longlong(FileFsFullSizeInfo.ActualAvailableAllocationUnits.QuadPart, 0);
    ok_eq_ulong(FileFsFullSizeInfo.SectorsPerAllocationUnit, 0);
    ok_eq_ulong(FileFsFullSizeInfo.BytesPerSector, 0);
    ok_eq_ulong(IoStatusBlock.Information, sizeof(FileFsFullSizeInfo));
}
Пример #2
0
static
VOID
TestQueryLink(
    _In_ HANDLE LinkHandle,
    _In_ PCUNICODE_STRING ExpectedTarget)
{
    NTSTATUS Status;
    WCHAR QueriedTargetBuffer[32];
    UNICODE_STRING QueriedTarget;
    ULONG ResultLength;
    PULONG pResultLength;
    ULONG i;

    for (i = 0; i < 2; i++)
    {
        if (i == 0)
        {
            pResultLength = &ResultLength;
        }
        else
        {
            pResultLength = NULL;
        }

        /* Query with NULL Buffer just gives us the length */
        RtlInitEmptyUnicodeString(&QueriedTarget, NULL, 0);
        if (pResultLength) ResultLength = 0x55555555;
        Status = ZwQuerySymbolicLinkObject(LinkHandle,
                                           &QueriedTarget,
                                           pResultLength);
        ok_eq_hex(Status, STATUS_BUFFER_TOO_SMALL);
        ok_eq_uint(QueriedTarget.Length, 0);
        ok_eq_uint(QueriedTarget.MaximumLength, 0);
        ok_eq_pointer(QueriedTarget.Buffer, NULL);
        if (pResultLength) ok_eq_ulong(ResultLength, ExpectedTarget->MaximumLength);

        /* Query with Length-1 buffer */
        RtlInitEmptyUnicodeString(&QueriedTarget,
                                  QueriedTargetBuffer,
                                  ExpectedTarget->Length - 1);
        RtlFillMemory(&QueriedTargetBuffer, sizeof(QueriedTargetBuffer), 0x55);
        if (pResultLength) ResultLength = 0x55555555;
        Status = ZwQuerySymbolicLinkObject(LinkHandle,
                                           &QueriedTarget,
                                           pResultLength);
        ok_eq_hex(Status, STATUS_BUFFER_TOO_SMALL);
        ok_eq_uint(QueriedTarget.Length, 0);
        ok_eq_uint(QueriedTarget.MaximumLength, ExpectedTarget->Length - 1);
        ok_eq_pointer(QueriedTarget.Buffer, QueriedTargetBuffer);
        ok_eq_uint(QueriedTarget.Buffer[0], 0x5555);
        if (pResultLength) ok_eq_ulong(ResultLength, ExpectedTarget->MaximumLength);

        /* Query with Length buffer */
        RtlInitEmptyUnicodeString(&QueriedTarget,
                                  QueriedTargetBuffer,
                                  ExpectedTarget->Length);
        RtlFillMemory(&QueriedTargetBuffer, sizeof(QueriedTargetBuffer), 0x55);
        if (pResultLength) ResultLength = 0x55555555;
        Status = ZwQuerySymbolicLinkObject(LinkHandle,
                                           &QueriedTarget,
                                           pResultLength);
        ok_eq_uint(QueriedTarget.MaximumLength, ExpectedTarget->Length);
        ok_eq_pointer(QueriedTarget.Buffer, QueriedTargetBuffer);
        if (pResultLength &&
            QueriedTarget.MaximumLength < ExpectedTarget->MaximumLength)
        {
            ok_eq_hex(Status, STATUS_BUFFER_TOO_SMALL);
            ok_eq_uint(QueriedTarget.Length, 0);
            ok_eq_uint(QueriedTarget.Buffer[0], 0x5555);
            if (pResultLength) ok_eq_ulong(ResultLength, ExpectedTarget->MaximumLength);
        }
        else
        {
            ok_eq_hex(Status, STATUS_SUCCESS);
            ok_eq_uint(QueriedTarget.Length, ExpectedTarget->Length);
            ok(RtlEqualUnicodeString(&QueriedTarget, ExpectedTarget, FALSE), "%wZ != %wZ\n", &QueriedTarget, ExpectedTarget);
            ok_eq_uint(QueriedTarget.Buffer[QueriedTarget.Length / sizeof(WCHAR)], 0x5555);
        }

        /* Query with Length+1 buffer */
        RtlInitEmptyUnicodeString(&QueriedTarget,
                                  QueriedTargetBuffer,
                                  ExpectedTarget->Length + 1);
        RtlFillMemory(&QueriedTargetBuffer, sizeof(QueriedTargetBuffer), 0x55);
        if (pResultLength) ResultLength = 0x55555555;
        Status = ZwQuerySymbolicLinkObject(LinkHandle,
                                           &QueriedTarget,
                                           pResultLength);
        ok_eq_uint(QueriedTarget.MaximumLength, ExpectedTarget->Length + 1);
        ok_eq_pointer(QueriedTarget.Buffer, QueriedTargetBuffer);
        if (pResultLength &&
            QueriedTarget.MaximumLength < ExpectedTarget->MaximumLength)
        {
            ok_eq_hex(Status, STATUS_BUFFER_TOO_SMALL);
            ok_eq_uint(QueriedTarget.Length, 0);
            ok_eq_uint(QueriedTarget.Buffer[0], 0x5555);
            if (pResultLength) ok_eq_ulong(ResultLength, ExpectedTarget->MaximumLength);
        }
        else
        {
            ok_eq_hex(Status, STATUS_SUCCESS);
            ok_eq_uint(QueriedTarget.Length, ExpectedTarget->Length);
            ok(RtlEqualUnicodeString(&QueriedTarget, ExpectedTarget, FALSE), "%wZ != %wZ\n", &QueriedTarget, ExpectedTarget);
            ok_eq_uint(QueriedTarget.Buffer[QueriedTarget.Length / sizeof(WCHAR)], 0x5555);
        }

        /* Query with Length+2 buffer */
        RtlInitEmptyUnicodeString(&QueriedTarget,
                                  QueriedTargetBuffer,
                                  ExpectedTarget->Length + sizeof(WCHAR));
        RtlFillMemory(&QueriedTargetBuffer, sizeof(QueriedTargetBuffer), 0x55);
        if (pResultLength) ResultLength = 0x55555555;
        Status = ZwQuerySymbolicLinkObject(LinkHandle,
                                           &QueriedTarget,
                                           pResultLength);
        ok_eq_hex(Status, STATUS_SUCCESS);
        ok_eq_uint(QueriedTarget.Length, ExpectedTarget->Length);
        ok_eq_uint(QueriedTarget.MaximumLength, ExpectedTarget->Length + sizeof(WCHAR));
        ok_eq_pointer(QueriedTarget.Buffer, QueriedTargetBuffer);
        ok(RtlEqualUnicodeString(&QueriedTarget, ExpectedTarget, FALSE), "%wZ != %wZ\n", &QueriedTarget, ExpectedTarget);
        if (pResultLength)
        {
            if (ExpectedTarget->MaximumLength >= ExpectedTarget->Length + sizeof(UNICODE_NULL))
                ok_eq_uint(QueriedTarget.Buffer[QueriedTarget.Length / sizeof(WCHAR)], 0);
            ok_eq_ulong(ResultLength, ExpectedTarget->MaximumLength);
        }
        else
        {
            ok_eq_uint(QueriedTarget.Buffer[QueriedTarget.Length / sizeof(WCHAR)], 0x5555);
        }

        /* Query with full-sized buffer */
        RtlInitEmptyUnicodeString(&QueriedTarget,
                                  QueriedTargetBuffer,
                                  sizeof(QueriedTargetBuffer));
        RtlFillMemory(&QueriedTargetBuffer, sizeof(QueriedTargetBuffer), 0x55);
        if (pResultLength) ResultLength = 0x55555555;
        Status = ZwQuerySymbolicLinkObject(LinkHandle,
                                           &QueriedTarget,
                                           pResultLength);
        ok_eq_hex(Status, STATUS_SUCCESS);
        ok_eq_uint(QueriedTarget.Length, ExpectedTarget->Length);
        ok_eq_uint(QueriedTarget.MaximumLength, sizeof(QueriedTargetBuffer));
        ok_eq_pointer(QueriedTarget.Buffer, QueriedTargetBuffer);
        ok(RtlEqualUnicodeString(&QueriedTarget, ExpectedTarget, FALSE), "%wZ != %wZ\n", &QueriedTarget, ExpectedTarget);
        if (pResultLength)
        {
            if (ExpectedTarget->MaximumLength >= ExpectedTarget->Length + sizeof(UNICODE_NULL))
                ok_eq_uint(QueriedTarget.Buffer[QueriedTarget.Length / sizeof(WCHAR)], 0);
            ok_eq_ulong(ResultLength, ExpectedTarget->MaximumLength);
        }
        else
        {
            ok_eq_uint(QueriedTarget.Buffer[QueriedTarget.Length / sizeof(WCHAR)], 0x5555);
        }
    }
}
Пример #3
0
/**
 * @name TestMessageHandler
 *
 * Test message handler routine
 *
 * @param DeviceObject
 *        Device Object.
 *        This is guaranteed not to have been touched by the dispatch function
 *        before the call to the IRP handler
 * @param Irp
 *        Device Object.
 *        This is guaranteed not to have been touched by the dispatch function
 *        before the call to the IRP handler, except for passing it to
 *        IoGetCurrentStackLocation
 * @param IoStackLocation
 *        Device Object.
 *        This is guaranteed not to have been touched by the dispatch function
 *        before the call to the IRP handler
 *
 * @return Status
 */
static
NTSTATUS
TestMessageHandler(
    IN PDEVICE_OBJECT DeviceObject,
    IN ULONG ControlCode,
    IN PVOID Buffer OPTIONAL,
    IN SIZE_T InLength,
    IN OUT PSIZE_T OutLength)
{
    NTSTATUS Status = STATUS_SUCCESS;

    switch (ControlCode)
    {
        case IOCTL_NOTIFY:
        {
            static int TimesReceived = 0;

            ++TimesReceived;
            ok(TimesReceived == 1, "Received control code 1 %d times\n", TimesReceived);
            ok_eq_pointer(Buffer, NULL);
            ok_eq_ulong((ULONG)InLength, 0LU);
            ok_eq_ulong((ULONG)*OutLength, 0LU);
            break;
        }
        case IOCTL_SEND_STRING:
        {
            static int TimesReceived = 0;
            ANSI_STRING ExpectedString = RTL_CONSTANT_STRING("yay");
            ANSI_STRING ReceivedString;

            ++TimesReceived;
            ok(TimesReceived == 1, "Received control code 2 %d times\n", TimesReceived);
            ok(Buffer != NULL, "Buffer is NULL\n");
            ok_eq_ulong((ULONG)InLength, (ULONG)ExpectedString.Length);
            ok_eq_ulong((ULONG)*OutLength, 0LU);
            ReceivedString.MaximumLength = ReceivedString.Length = (USHORT)InLength;
            ReceivedString.Buffer = Buffer;
            ok(RtlCompareString(&ExpectedString, &ReceivedString, FALSE) == 0, "Received string: %Z\n", &ReceivedString);
            break;
        }
        case IOCTL_SEND_MYSTRUCT:
        {
            static int TimesReceived = 0;
            MY_STRUCT ExpectedStruct = { 123, ":D" };
            MY_STRUCT ResultStruct = { 456, "!!!" };

            ++TimesReceived;
            ok(TimesReceived == 1, "Received control code 3 %d times\n", TimesReceived);
            ok(Buffer != NULL, "Buffer is NULL\n");
            ok_eq_ulong((ULONG)InLength, (ULONG)sizeof ExpectedStruct);
            ok_eq_ulong((ULONG)*OutLength, 2LU * sizeof ExpectedStruct);
            if (!skip(Buffer && InLength >= sizeof ExpectedStruct, "Cannot read from buffer!\n"))
                ok(RtlCompareMemory(&ExpectedStruct, Buffer, sizeof ExpectedStruct) == sizeof ExpectedStruct, "Buffer does not contain expected values\n");

            if (!skip(Buffer && *OutLength >= 2 * sizeof ExpectedStruct, "Cannot write to buffer!\n"))
            {
                RtlCopyMemory((PCHAR)Buffer + sizeof ExpectedStruct, &ResultStruct, sizeof ResultStruct);
                *OutLength = 2 * sizeof ExpectedStruct;
            }
            break;
        }
        default:
            ok(0, "Got an unknown message! DeviceObject=%p, ControlCode=%lu, Buffer=%p, In=%lu, Out=%lu bytes\n",
                    DeviceObject, ControlCode, Buffer, InLength, *OutLength);
            break;
    }

    return Status;
}
Пример #4
0
static
VOID
TestDriverObject(
    IN PDRIVER_OBJECT DriverObject,
    IN PCUNICODE_STRING RegistryPath OPTIONAL,
    IN DRIVER_STATUS DriverStatus)
{
    BOOLEAN CheckThisDispatchRoutine;
    PVOID FirstMajorFunc;
    int i;
    UNICODE_STRING HardwareDatabase = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM");
    UNICODE_STRING RegPath = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\ControlSet001\\Services\\Kmtest-IoDeviceObject");
    UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"\\Driver\\Kmtest-IoDeviceObject");
    UNICODE_STRING ServiceKeyName = RTL_CONSTANT_STRING(L"Kmtest-IoDeviceObject");
    BOOLEAN Equal;

    ok(DriverObject->Size == sizeof(DRIVER_OBJECT), "Size does not match, got %x\n",DriverObject->Size);
    ok(DriverObject->Type == 4, "Type does not match 4. got %d\n", DriverObject->Type);

    if (DriverStatus == DriverStatusEntry)
    {
        ok(DriverObject->DeviceObject == NULL, "Expected DeviceObject pointer to be 0, got %p\n",
            DriverObject->DeviceObject);
        ok (DriverObject->Flags == DRVO_LEGACY_DRIVER,
            "Expected Flags to be DRVO_LEGACY_DRIVER, got %lu\n",
            DriverObject->Flags);

        ok(DriverObject->DriverStart < (PVOID)TestEntry,
           "DriverStart is %p, expected < %p\n",
           DriverObject->DriverStart, (PVOID)TestEntry);
        ok(DriverObject->DriverSize > 0x2000,
           "DriverSize 0x%lx\n", DriverObject->DriverSize);
        ok_eq_pointer(DriverObject->DriverExtension, (PDRIVER_EXTENSION)(DriverObject + 1));
        ok_eq_pointer(DriverObject->DriverExtension->DriverObject, DriverObject);
        ok_eq_pointer(DriverObject->DriverExtension->AddDevice, NULL);
        ok_eq_ulong(DriverObject->DriverExtension->Count, 0UL);
        Equal = RtlEqualUnicodeString(RegistryPath,
                                      &RegPath,
                                      FALSE);
        ok(Equal, "RegistryPath is '%wZ'\n", RegistryPath);
        ok((ULONG_PTR)RegistryPath % PAGE_SIZE == 0, "RegistryPath %p not page-aligned\n", RegistryPath);
        ok_eq_pointer(RegistryPath->Buffer, (PWCHAR)(RegistryPath + 1));
        ok_eq_uint(RegistryPath->MaximumLength, RegistryPath->Length);
        Equal = RtlEqualUnicodeString(&DriverObject->DriverExtension->ServiceKeyName,
                                      &ServiceKeyName,
                                      FALSE);
        ok(Equal, "ServiceKeyName is '%wZ'\n", &DriverObject->DriverExtension->ServiceKeyName);
        ok_eq_tag(KmtGetPoolTag(DriverObject->DriverExtension->ServiceKeyName.Buffer), '  oI');
        ok_eq_uint((KmtGetPoolType(DriverObject->DriverExtension->ServiceKeyName.Buffer) - 1) & BASE_POOL_TYPE_MASK, NonPagedPool);
        ok_eq_uint(DriverObject->DriverExtension->ServiceKeyName.MaximumLength, DriverObject->DriverExtension->ServiceKeyName.Length + sizeof(UNICODE_NULL));
        ok_eq_uint(DriverObject->DriverExtension->ServiceKeyName.Buffer[DriverObject->DriverExtension->ServiceKeyName.Length / sizeof(WCHAR)], UNICODE_NULL);
        Equal = RtlEqualUnicodeString(&DriverObject->DriverName,
                                      &DriverName,
                                      FALSE);
        ok(Equal, "DriverName is '%wZ'\n", &DriverObject->DriverName);
        ok_eq_tag(KmtGetPoolTag(DriverObject->DriverName.Buffer), '  oI');
        ok_eq_uint((KmtGetPoolType(DriverObject->DriverName.Buffer) - 1) & BASE_POOL_TYPE_MASK, PagedPool);
        ok_eq_uint(DriverObject->DriverName.MaximumLength, DriverObject->DriverName.Length);
        // TODO: show that both string and buffer are constants inside ntos
        Equal = RtlEqualUnicodeString(DriverObject->HardwareDatabase,
                                      &HardwareDatabase,
                                      FALSE);
        ok(Equal, "HardwareDatabase is '%wZ'\n", DriverObject->HardwareDatabase);
        ok_eq_uint(DriverObject->HardwareDatabase->MaximumLength, DriverObject->HardwareDatabase->Length + sizeof(UNICODE_NULL));
        ok_eq_uint(DriverObject->HardwareDatabase->Buffer[DriverObject->HardwareDatabase->Length / sizeof(WCHAR)], UNICODE_NULL);
        ok(DriverObject->DriverInit == DriverEntry,
           "DriverInit is %p, expected %p\n",
           (PVOID)DriverObject->DriverInit, (PVOID)DriverEntry);
    }
    else if (DriverStatus == DriverStatusIrp)
    {
        ok(DriverObject->DeviceObject != NULL, "Expected DeviceObject pointer to non null\n");
        ok (DriverObject->Flags == (DRVO_LEGACY_DRIVER | DRVO_INITIALIZED),
            "Expected Flags to be DRVO_LEGACY_DRIVER | DRVO_INITIALIZED, got %lu\n",
            DriverObject->Flags);
    }
    else if (DriverStatus == DriverStatusUnload)
    {
        ok(DriverObject->DeviceObject != NULL, "Expected DeviceObject pointer to non null\n");
        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\n",
            DriverObject->Flags);
    }
    else
        ASSERT(FALSE);

    /* Select a routine that was not changed */
    FirstMajorFunc = DriverObject->MajorFunction[1];
    ok(FirstMajorFunc != 0, "Expected MajorFunction[1] to be non NULL\n");

    if (!skip(FirstMajorFunc != NULL, "First major function not set!\n"))
    {
        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\n",
                    i, FirstMajorFunc);
            }
        }
    }
}