summaryrefslogtreecommitdiffstats
path: root/private/nw/test/testnw.c
blob: 7c95555f1b7d15a034b1e602e16a8d5f54d53081 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#define WIN32_CONSOLE_APP
#include <windows.h>
#include <stdio.h>
#include <ntddnwfs.h>

#define CANCEL


BOOLEAN test1();

int
_cdecl
main(
    int argc,
    char *argv[]
    )
{
    UCHAR error = FALSE;
    DefineDosDevice(DDD_RAW_TARGET_PATH, "R:", "\\Device\\NwRdr\\R:\\NETWARE311");
    printf( "Test1...\n" );
    if (!test1()) {
        printf("Error:  Test 1 failed\n");
        error = TRUE;
    }
    return error;
}



BOOLEAN
test1()
{
    HANDLE FileHandle;
    NTSTATUS Status;
    OBJECT_ATTRIBUTES ObjectAttributes;
    UNICODE_STRING UnicodeString;
    IO_STATUS_BLOCK IoStatus;

    NWR_REQUEST_PACKET Input;

    printf( "test 1: opening\n");

    RtlInitUnicodeString( &UnicodeString, L"\\Device\\NwRdr" );

    InitializeObjectAttributes( &ObjectAttributes,
                                  &UnicodeString,
                                  0,
                                  NULL,
                                  NULL
                                );
/*    Status = NtCreateFile( &FileHandle,
                           FILE_LIST_DIRECTORY | SYNCHRONIZE,
                           &ObjectAttributes,
                           &IoStatus,
                           (PLARGE_INTEGER) NULL,
                           0L,
                           0L,
                           FILE_CREATE,
                           FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_ALERT,
                           (PVOID) NULL,
                           0L );
*/
      Status = NtOpenFile ( &FileHandle,
                            FILE_LIST_DIRECTORY | SYNCHRONIZE,
                            &ObjectAttributes,
                            &IoStatus,
                            FILE_SHARE_READ,
                            FILE_DIRECTORY_FILE);

    if (Status != STATUS_SUCCESS) {
        printf( "test 1: Wrong return value %X - open \n",Status);
        return FALSE;
    }

    if (IoStatus.Status != STATUS_SUCCESS) {
        printf( "test 2: Wrong I/O Status value %X - open \n",IoStatus.Status);
        return FALSE;
    }

    printf( "test 1: opened device successfully\n");

    Input.Version = REQUEST_PACKET_VERSION;
    Input.Parameters.DebugValue.DebugFlags = 0xffffffff;

    NtFsControlFile( FileHandle,
                     NULL,
                     NULL,
                     NULL,
                     &IoStatus,
                     FSCTL_NWR_DEBUG,
                     &Input,
                     sizeof(Input),
                     NULL,
                     0);

    if (Status != STATUS_SUCCESS) {
        printf( "test 1: Wrong return value %X - SetDebug \n",Status);
        return FALSE;
    }

    if (IoStatus.Status != STATUS_SUCCESS) {
        printf( "test 2: Wrong I/O Status value %X - SetDebug \n",IoStatus.Status);
        return FALSE;
    }

    printf( "test 1: set debug trace level successfully\n");

    //
    // Now close the device
    //

    printf("test 1:  closing device\n");

    Status = NtClose( FileHandle );
    if (Status != STATUS_SUCCESS) {
        printf( "test 1: Wrong return value %lX - close \n",Status);
        return FALSE;
    }
    return TRUE;
}