2 * Unit test suite for object manager functions
4 * Copyright 2005 Robert Shearman
5 * Copyright 2005 Vitaliy Margolen
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "ntdll_test.h"
28 static NTSTATUS (WINAPI
*pNtCreateEvent
) ( PHANDLE
, ACCESS_MASK
, const POBJECT_ATTRIBUTES
, BOOLEAN
, BOOLEAN
);
29 static NTSTATUS (WINAPI
*pNtCreateMutant
)( PHANDLE
, ACCESS_MASK
, const POBJECT_ATTRIBUTES
, BOOLEAN
);
30 static NTSTATUS (WINAPI
*pNtOpenMutant
) ( PHANDLE
, ACCESS_MASK
, const POBJECT_ATTRIBUTES
);
31 static NTSTATUS (WINAPI
*pNtOpenFile
) ( PHANDLE
, ACCESS_MASK
, POBJECT_ATTRIBUTES
, PIO_STATUS_BLOCK
, ULONG
, ULONG
);
32 static NTSTATUS (WINAPI
*pNtClose
) ( HANDLE
);
33 static VOID (WINAPI
*pRtlInitUnicodeString
)( PUNICODE_STRING
, LPCWSTR
);
34 static NTSTATUS (WINAPI
*pNtCreateNamedPipeFile
)( PHANDLE
, ULONG
, POBJECT_ATTRIBUTES
, PIO_STATUS_BLOCK
,
35 ULONG
, ULONG
, ULONG
, ULONG
, ULONG
, ULONG
, ULONG
, ULONG
, ULONG
, PLARGE_INTEGER
);
38 void test_case_sensitive (void)
40 static const WCHAR buffer1
[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t',0};
41 static const WCHAR buffer2
[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','T','e','s','t',0};
42 static const WCHAR buffer3
[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','T','E','s','t',0};
43 static const WCHAR buffer4
[] = {'\\','B','A','S','E','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t',0};
45 OBJECT_ATTRIBUTES attr
;
47 HANDLE Event
, Mutant
, h
;
49 pRtlInitUnicodeString(&str
, buffer1
);
50 InitializeObjectAttributes(&attr
, &str
, 0, 0, NULL
);
51 status
= pNtCreateMutant(&Mutant
, GENERIC_ALL
, &attr
, FALSE
);
52 ok(status
== STATUS_SUCCESS
, "Failed to create Mutant(%08lx)\n", status
);
54 status
= pNtCreateEvent(&Event
, GENERIC_ALL
, &attr
, FALSE
, FALSE
);
55 ok(status
== STATUS_OBJECT_NAME_COLLISION
,
56 "NtCreateEvent should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status
);
58 pRtlInitUnicodeString(&str
, buffer2
);
59 InitializeObjectAttributes(&attr
, &str
, 0, 0, NULL
);
60 status
= pNtCreateEvent(&Event
, GENERIC_ALL
, &attr
, FALSE
, FALSE
);
61 ok(status
== STATUS_SUCCESS
, "Failed to create Event(%08lx)\n", status
);
63 pRtlInitUnicodeString(&str
, buffer3
);
64 InitializeObjectAttributes(&attr
, &str
, OBJ_CASE_INSENSITIVE
, 0, NULL
);
65 status
= pNtOpenMutant(&h
, GENERIC_ALL
, &attr
);
66 todo_wine
ok(status
== STATUS_OBJECT_TYPE_MISMATCH
,
67 "NtOpenMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status
);
71 pRtlInitUnicodeString(&str
, buffer4
);
72 InitializeObjectAttributes(&attr
, &str
, OBJ_CASE_INSENSITIVE
, 0, NULL
);
73 status
= pNtCreateMutant(&Mutant
, GENERIC_ALL
, &attr
, FALSE
);
74 todo_wine
ok(status
== STATUS_OBJECT_NAME_COLLISION
,
75 "NtCreateMutant should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status
);
77 status
= pNtCreateEvent(&h
, GENERIC_ALL
, &attr
, FALSE
, FALSE
);
78 ok(status
== STATUS_OBJECT_NAME_COLLISION
,
79 "NtCreateEvent should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status
);
82 status
= pNtCreateMutant(&Mutant
, GENERIC_ALL
, &attr
, FALSE
);
83 todo_wine
ok(status
== STATUS_OBJECT_PATH_NOT_FOUND
,
84 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status
);
89 void test_namespace_pipe(void)
91 static const WCHAR buffer1
[] = {'\\','?','?','\\','P','I','P','E','\\','t','e','s','t','\\','p','i','p','e',0};
92 static const WCHAR buffer2
[] = {'\\','?','?','\\','P','I','P','E','\\','T','E','S','T','\\','P','I','P','E',0};
93 static const WCHAR buffer3
[] = {'\\','?','?','\\','p','i','p','e','\\','t','e','s','t','\\','p','i','p','e',0};
94 static const WCHAR buffer4
[] = {'\\','?','?','\\','p','i','p','e','\\','t','e','s','t',0};
95 OBJECT_ATTRIBUTES attr
;
99 LARGE_INTEGER timeout
;
102 timeout
.QuadPart
= -10000;
104 pRtlInitUnicodeString(&str
, buffer1
);
105 InitializeObjectAttributes(&attr
, &str
, 0, 0, NULL
);
106 status
= pNtCreateNamedPipeFile(&pipe
, GENERIC_READ
|GENERIC_WRITE
, &attr
, &iosb
, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
107 FILE_CREATE
, FILE_PIPE_FULL_DUPLEX
, FALSE
, FALSE
, FALSE
, 1, 256, 256, &timeout
);
108 ok(status
== STATUS_SUCCESS
, "Failed to create NamedPipe(%08lx)\n", status
);
110 status
= pNtCreateNamedPipeFile(&pipe
, GENERIC_READ
|GENERIC_WRITE
, &attr
, &iosb
, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
111 FILE_CREATE
, FILE_PIPE_FULL_DUPLEX
, FALSE
, FALSE
, FALSE
, 1, 256, 256, &timeout
);
112 todo_wine
ok(status
== STATUS_INSTANCE_NOT_AVAILABLE
,
113 "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08lx)\n", status
);
115 pRtlInitUnicodeString(&str
, buffer2
);
116 InitializeObjectAttributes(&attr
, &str
, 0, 0, NULL
);
117 status
= pNtCreateNamedPipeFile(&pipe
, GENERIC_READ
|GENERIC_WRITE
, &attr
, &iosb
, FILE_SHARE_READ
|FILE_SHARE_WRITE
,
118 FILE_CREATE
, FILE_PIPE_FULL_DUPLEX
, FALSE
, FALSE
, FALSE
, 1, 256, 256, &timeout
);
119 todo_wine
ok(status
== STATUS_INSTANCE_NOT_AVAILABLE
,
120 "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08lx)\n", status
);
122 attr
.Attributes
= OBJ_CASE_INSENSITIVE
;
123 status
= pNtOpenFile(&h
, GENERIC_READ
, &attr
, &iosb
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_OPEN
);
124 ok(status
== STATUS_SUCCESS
, "Failed to open NamedPipe(%08lx)\n", status
);
127 pRtlInitUnicodeString(&str
, buffer3
);
128 InitializeObjectAttributes(&attr
, &str
, 0, 0, NULL
);
129 status
= pNtOpenFile(&h
, GENERIC_READ
, &attr
, &iosb
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_OPEN
);
130 todo_wine
ok(status
== STATUS_OBJECT_PATH_NOT_FOUND
,
131 "pNtOpenFile should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status
);
133 pRtlInitUnicodeString(&str
, buffer4
);
134 InitializeObjectAttributes(&attr
, &str
, OBJ_CASE_INSENSITIVE
, 0, NULL
);
135 status
= pNtOpenFile(&h
, GENERIC_READ
, &attr
, &iosb
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, FILE_OPEN
);
136 todo_wine
ok(status
== STATUS_OBJECT_NAME_NOT_FOUND
,
137 "pNtOpenFile should have failed with STATUS_OBJECT_NAME_NOT_FOUND got(%08lx)\n", status
);
144 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
147 pNtCreateEvent
= (void *)GetProcAddress(hntdll
, "NtCreateEvent");
148 pNtCreateMutant
= (void *)GetProcAddress(hntdll
, "NtCreateMutant");
149 pNtOpenMutant
= (void *)GetProcAddress(hntdll
, "NtOpenMutant");
150 pNtOpenFile
= (void *)GetProcAddress(hntdll
, "NtOpenFile");
151 pNtClose
= (void *)GetProcAddress(hntdll
, "NtClose");
152 pRtlInitUnicodeString
= (void *)GetProcAddress(hntdll
, "RtlInitUnicodeString");
153 pNtCreateNamedPipeFile
= (void *)GetProcAddress(hntdll
, "NtCreateNamedPipeFile");
155 test_case_sensitive();
156 test_namespace_pipe();