ReactOS 0.4.15-dev-7788-g1ad9096
change.c File Reference
#include <ntstatus.h>
#include <windows.h>
#include <winnt.h>
#include <winternl.h>
#include <winerror.h>
#include <stdio.h>
#include "wine/test.h"
Include dependency graph for change.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

static NTSTATUS (WINAPI *pNtNotifyChangeDirectoryFile)(HANDLE
 
static void test_ntncdf (void)
 
static void test_ntncdf_async (void)
 
 START_TEST (change)
 

Variables

static HANDLE
 
static PIO_APC_ROUTINE
 
static PVOID
 
static PIO_STATUS_BLOCK
 
static ULONG
 
static BOOLEAN
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 22 of file change.c.

Function Documentation

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtNotifyChangeDirectoryFile)
static

◆ START_TEST()

START_TEST ( change  )

Definition at line 313 of file change.c.

314{
316 if (!hntdll)
317 {
318 win_skip("not running on NT, skipping test\n");
319 return;
320 }
321
322 pNtNotifyChangeDirectoryFile = (void *)GetProcAddress(hntdll, "NtNotifyChangeDirectoryFile");
323 pNtCancelIoFile = (void *)GetProcAddress(hntdll, "NtCancelIoFile");
324
325 if (!pNtNotifyChangeDirectoryFile || !pNtCancelIoFile)
326 {
327 win_skip("missing functions, skipping test\n");
328 return;
329 }
330
331 test_ntncdf();
333}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static HINSTANCE hntdll
Definition: process.c:66
static void test_ntncdf(void)
Definition: change.c:37
static void test_ntncdf_async(void)
Definition: change.c:165
#define win_skip
Definition: test.h:160

◆ test_ntncdf()

static void test_ntncdf ( void  )
static

Definition at line 37 of file change.c.

38{
39 NTSTATUS r;
40 HANDLE hdir, hEvent;
41 char buffer[0x1000];
42 DWORD fflags, filter = 0;
44 WCHAR path[MAX_PATH], subdir[MAX_PATH];
45 static const WCHAR szBoo[] = { '\\','b','o','o',0 };
46 static const WCHAR szHoo[] = { '\\','h','o','o',0 };
48
50 ok( r != 0, "temp path failed\n");
51 if (!r)
52 return;
53
54 lstrcatW( path, szBoo );
55 lstrcpyW( subdir, path );
56 lstrcatW( subdir, szHoo );
57
58 RemoveDirectoryW( subdir );
60
62 ok( r == TRUE, "failed to create directory\n");
63
64 r = pNtNotifyChangeDirectoryFile(NULL,NULL,NULL,NULL,NULL,NULL,0,0,0);
65 ok(r==STATUS_ACCESS_VIOLATION, "should return access violation\n");
66
69 OPEN_EXISTING, fflags, NULL);
70 ok( hdir != INVALID_HANDLE_VALUE, "failed to open directory\n");
71
72 hEvent = CreateEventA( NULL, 0, 0, NULL );
73
74 r = pNtNotifyChangeDirectoryFile(hdir,NULL,NULL,NULL,&iosb,NULL,0,0,0);
75 ok(r==STATUS_INVALID_PARAMETER, "should return invalid parameter\n");
76
77 r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,NULL,0,0,0);
78 ok(r==STATUS_INVALID_PARAMETER, "should return invalid parameter\n");
79
88
89 U(iosb).Status = 1;
90 iosb.Information = 1;
91 r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,buffer,sizeof buffer,-1,0);
92 ok(r==STATUS_INVALID_PARAMETER, "should return invalid parameter\n");
93
94 ok( U(iosb).Status == 1, "information wrong\n");
95 ok( iosb.Information == 1, "information wrong\n");
96
97 U(iosb).Status = 1;
98 iosb.Information = 0;
99 r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0);
100 ok(r==STATUS_PENDING, "should return status pending\n");
101
102 r = WaitForSingleObject( hEvent, 100 );
103 ok( r == STATUS_TIMEOUT, "should timeout\n" );
104
105 r = WaitForSingleObject( hdir, 100 );
106 ok( r == STATUS_TIMEOUT, "should timeout\n" );
107
108 r = CreateDirectoryW( subdir, NULL );
109 ok( r == TRUE, "failed to create directory\n");
110
111 r = WaitForSingleObject( hdir, 100 );
112 ok( r == STATUS_TIMEOUT, "should timeout\n" );
113
114 r = WaitForSingleObject( hEvent, 100 );
115 ok( r == WAIT_OBJECT_0, "event should be ready\n" );
116
117 ok( U(iosb).Status == STATUS_SUCCESS, "information wrong\n");
118 ok( iosb.Information == 0x12, "information wrong\n");
119
121 ok( pfni->NextEntryOffset == 0, "offset wrong\n" );
122 ok( pfni->Action == FILE_ACTION_ADDED, "action wrong\n" );
123 ok( pfni->FileNameLength == 6, "len wrong\n" );
124 ok( !memcmp(pfni->FileName,&szHoo[1],6), "name wrong\n" );
125
126 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,buffer,sizeof buffer,0,0);
127 ok(r==STATUS_INVALID_PARAMETER, "should return invalid parameter\n");
128
129 r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,buffer,sizeof buffer,0,0);
130 ok(r==STATUS_INVALID_PARAMETER, "should return invalid parameter\n");
131
133
134 U(iosb).Status = 1;
135 iosb.Information = 1;
136 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,NULL,0,filter,0);
137 ok(r==STATUS_PENDING, "should status pending\n");
138
139 ok( U(iosb).Status == 1, "information wrong\n");
140 ok( iosb.Information == 1, "information wrong\n");
141
142 r = WaitForSingleObject( hdir, 0 );
143 ok( r == STATUS_TIMEOUT, "should timeout\n" );
144
145 r = RemoveDirectoryW( subdir );
146 ok( r == TRUE, "failed to remove directory\n");
147
148 r = WaitForSingleObject( hdir, 100 );
149 ok( r == WAIT_OBJECT_0, "should be ready\n" );
150
151 r = WaitForSingleObject( hdir, 100 );
152 ok( r == WAIT_OBJECT_0, "should be ready\n" );
153
154 ok( U(iosb).Status == STATUS_NOTIFY_ENUM_DIR, "information wrong\n");
155 ok( iosb.Information == 0, "information wrong\n");
156
157 CloseHandle(hdir);
159
161 ok( r == TRUE, "failed to remove directory\n");
162}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define U(x)
Definition: wordpad.c:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define lstrcpyW
Definition: compat.h:749
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint buffer
Definition: glext.h:5915
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
static HANDLE hEvent
Definition: comm.c:54
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define SYNCHRONIZE
Definition: nt_native.h:61
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_NOTIFY_ENUM_DIR
Definition: ntstatus.h:91
#define STATUS_SUCCESS
Definition: shellext.h:65
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WAIT_OBJECT_0
Definition: winbase.h:406
struct _FILE_NOTIFY_INFORMATION * PFILE_NOTIFY_INFORMATION
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_NOTIFY_CHANGE_LAST_ACCESS
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_NOTIFY_CHANGE_SECURITY
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FILE_NOTIFY_CHANGE_CREATION
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_ACTION_ADDED
#define FILE_NOTIFY_CHANGE_DIR_NAME
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_ntncdf_async()

static void test_ntncdf_async ( void  )
static

Definition at line 165 of file change.c.

166{
167 NTSTATUS r;
168 HANDLE hdir, hEvent;
169 char buffer[0x1000];
170 DWORD fflags, filter = 0;
171 IO_STATUS_BLOCK iosb, iosb2;
172 WCHAR path[MAX_PATH], subdir[MAX_PATH];
173 static const WCHAR szBoo[] = { '\\','b','o','o',0 };
174 static const WCHAR szHoo[] = { '\\','h','o','o',0 };
176
178 ok( r != 0, "temp path failed\n");
179 if (!r)
180 return;
181
182 lstrcatW( path, szBoo );
183 lstrcpyW( subdir, path );
184 lstrcatW( subdir, szHoo );
185
186 RemoveDirectoryW( subdir );
188
190 ok( r == TRUE, "failed to create directory\n");
191
192 r = pNtNotifyChangeDirectoryFile(NULL,NULL,NULL,NULL,NULL,NULL,0,0,0);
193 ok(r==STATUS_ACCESS_VIOLATION, "should return access violation\n");
194
197 OPEN_EXISTING, fflags, NULL);
198 ok( hdir != INVALID_HANDLE_VALUE, "failed to open directory\n");
199
200 hEvent = CreateEventA( NULL, 0, 0, NULL );
201
210
211
212 U(iosb).Status = 0x01234567;
213 iosb.Information = 0x12345678;
214 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0);
215 ok(r==STATUS_PENDING, "should status pending\n");
216 ok(U(iosb).Status == 0x01234567, "status set too soon\n");
217 ok(iosb.Information == 0x12345678, "info set too soon\n");
218
219 r = CreateDirectoryW( subdir, NULL );
220 ok( r == TRUE, "failed to create directory\n");
221
222 r = WaitForSingleObject( hdir, 100 );
223 ok( r == WAIT_OBJECT_0, "should be ready\n" );
224
225 ok(U(iosb).Status == STATUS_SUCCESS, "status not successful\n");
226 ok(iosb.Information == 0x12, "info not set\n");
227
229 ok( pfni->NextEntryOffset == 0, "offset wrong\n" );
230 ok( pfni->Action == FILE_ACTION_ADDED, "action wrong\n" );
231 ok( pfni->FileNameLength == 6, "len wrong\n" );
232 ok( !memcmp(pfni->FileName,&szHoo[1],6), "name wrong\n" );
233
234 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0);
235 ok(r==STATUS_PENDING, "should status pending\n");
236
237 r = RemoveDirectoryW( subdir );
238 ok( r == TRUE, "failed to remove directory\n");
239
240 r = WaitForSingleObject( hdir, 0 );
241 ok( r == WAIT_OBJECT_0, "should be ready\n" );
242
243 ok(U(iosb).Status == STATUS_SUCCESS, "status not successful\n");
244 ok(iosb.Information == 0x12, "info not set\n");
245
246 ok( pfni->NextEntryOffset == 0, "offset wrong\n" );
247 ok( pfni->Action == FILE_ACTION_REMOVED, "action wrong\n" );
248 ok( pfni->FileNameLength == 6, "len wrong\n" );
249 ok( !memcmp(pfni->FileName,&szHoo[1],6), "name wrong\n" );
250
251 /* check APCs */
252 U(iosb).Status = 0;
253 iosb.Information = 0;
254
255 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,NULL,0,filter,0);
256 ok(r==STATUS_PENDING, "should status pending\n");
257
258 r = CreateDirectoryW( subdir, NULL );
259 ok( r == TRUE, "failed to create directory\n");
260
261 r = WaitForSingleObject( hdir, 0 );
262 ok( r == WAIT_OBJECT_0, "should be ready\n" );
263
264 ok(U(iosb).Status == STATUS_NOTIFY_ENUM_DIR, "status not successful\n");
265 ok(iosb.Information == 0, "info not set\n");
266
267 U(iosb).Status = 0;
268 iosb.Information = 0;
269
270 r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0);
271 ok(r==STATUS_PENDING, "should status pending\n");
272
273 r = RemoveDirectoryW( subdir );
274 ok( r == TRUE, "failed to remove directory\n");
275
277 ok( r == WAIT_OBJECT_0, "should be ready\n" );
278
279 ok(U(iosb).Status == STATUS_SUCCESS, "status not successful\n");
280 ok(iosb.Information == 0x12, "info not set\n");
281
282
283 U(iosb).Status = 0x01234567;
284 iosb.Information = 0x12345678;
285 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0);
286 ok(r==STATUS_PENDING, "should status pending\n");
287
288 U(iosb2).Status = 0x01234567;
289 iosb2.Information = 0x12345678;
290 r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb2,buffer,sizeof buffer,filter,0);
291 ok(r==STATUS_PENDING, "should status pending\n");
292
293 ok(U(iosb).Status == 0x01234567, "status set too soon\n");
294 ok(iosb.Information == 0x12345678, "info set too soon\n");
295
296 r = pNtCancelIoFile(hdir, &iosb);
297 ok( r == STATUS_SUCCESS, "cancel failed\n");
298
299 CloseHandle(hdir);
300
301 ok(U(iosb).Status == STATUS_SUCCESS, "status wrong\n");
302 ok(U(iosb2).Status == STATUS_CANCELLED, "status wrong %x\n",U(iosb2).Status);
303
304 ok(iosb.Information == 0, "info wrong\n");
305 ok(iosb2.Information == 0, "info wrong\n");
306
308 ok( r == TRUE, "failed to remove directory\n");
309
311}
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define FILE_ACTION_REMOVED

Referenced by START_TEST().

Variable Documentation

◆ BOOLEAN

Definition at line 32 of file change.c.

◆ HANDLE

Definition at line 31 of file change.c.

◆ PIO_APC_ROUTINE

PIO_APC_ROUTINE

Definition at line 31 of file change.c.

◆ PIO_STATUS_BLOCK

Definition at line 32 of file change.c.

◆ PVOID

Definition at line 31 of file change.c.

◆ ULONG

Definition at line 32 of file change.c.