Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
bad5f92f
Commit
bad5f92f
authored
Feb 06, 2006
by
Mike McCormack
Committed by
Alexandre Julliard
Feb 06, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add some more tests for NtNotifyChangeDirectoryFile.
parent
01932119
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
217 additions
and
13 deletions
+217
-13
change.c
dlls/ntdll/tests/change.c
+217
-13
No files found.
dlls/ntdll/tests/change.c
View file @
bad5f92f
...
...
@@ -32,9 +32,12 @@ typedef NTSTATUS (WINAPI *fnNtNotifyChangeDirectoryFile)(
PIO_STATUS_BLOCK
,
PVOID
,
ULONG
,
ULONG
,
BOOLEAN
);
fnNtNotifyChangeDirectoryFile
pNtNotifyChangeDirectoryFile
;
typedef
NTSTATUS
(
WINAPI
*
fnNtCancelIoFile
)(
HANDLE
,
PIO_STATUS_BLOCK
);
fnNtCancelIoFile
pNtCancelIoFile
;
static
void
test_ntncdf
(
void
)
{
HMODULE
hntdll
=
GetModuleHandle
(
"ntdll"
);
NTSTATUS
r
;
HANDLE
hdir
,
hEvent
;
char
buffer
[
0x1000
];
...
...
@@ -43,11 +46,7 @@ static void test_ntncdf(void)
WCHAR
path
[
MAX_PATH
],
subdir
[
MAX_PATH
];
static
const
WCHAR
szBoo
[]
=
{
'\\'
,
'b'
,
'o'
,
'o'
,
0
};
static
const
WCHAR
szHoo
[]
=
{
'\\'
,
'h'
,
'o'
,
'o'
,
0
};
pNtNotifyChangeDirectoryFile
=
(
fnNtNotifyChangeDirectoryFile
)
GetProcAddress
(
hntdll
,
"NtNotifyChangeDirectoryFile"
);
if
(
!
pNtNotifyChangeDirectoryFile
)
return
;
PFILE_NOTIFY_INFORMATION
pfni
;
r
=
GetTempPathW
(
MAX_PATH
,
path
);
ok
(
r
!=
0
,
"temp path failed
\n
"
);
...
...
@@ -89,40 +88,245 @@ static void test_ntncdf(void)
filter
|=
FILE_NOTIFY_CHANGE_CREATION
;
filter
|=
FILE_NOTIFY_CHANGE_SECURITY
;
iosb
.
Status
=
1
;
iosb
.
Information
=
1
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
hEvent
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
-
1
,
0
);
ok
(
r
==
STATUS_INVALID_PARAMETER
,
"should return invalid parameter
\n
"
);
ok
(
iosb
.
Status
==
1
,
"information wrong
\n
"
);
ok
(
iosb
.
Information
==
1
,
"information wrong
\n
"
);
iosb
.
Status
=
1
;
iosb
.
Information
=
0
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
hEvent
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should return status pending
\n
"
);
r
=
WaitForSingleObject
(
hEvent
,
0
);
ok
(
r
==
STATUS_TIMEOUT
,
"event shouldn't be ready
\n
"
);
ok
(
r
==
STATUS_TIMEOUT
,
"should timeout
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
0
);
ok
(
r
==
STATUS_TIMEOUT
,
"should timeout
\n
"
);
r
=
CreateDirectoryW
(
subdir
,
NULL
);
ok
(
r
==
TRUE
,
"failed to create directory
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
0
);
ok
(
r
==
STATUS_TIMEOUT
,
"should timeout
\n
"
);
r
=
WaitForSingleObject
(
hEvent
,
0
);
ok
(
r
==
WAIT_OBJECT_0
,
"event wasn't ready
\n
"
);
ok
(
r
==
WAIT_OBJECT_0
,
"event should be ready
\n
"
);
ok
(
iosb
.
Status
==
STATUS_SUCCESS
,
"information wrong
\n
"
);
ok
(
iosb
.
Information
==
0x12
,
"information wrong
\n
"
);
pfni
=
(
PFILE_NOTIFY_INFORMATION
)
buffer
;
ok
(
pfni
->
NextEntryOffset
==
0
,
"offset wrong
\n
"
);
ok
(
pfni
->
Action
==
FILE_ACTION_ADDED
,
"action wrong
\n
"
);
ok
(
pfni
->
FileNameLength
==
6
,
"len wrong
\n
"
);
ok
(
!
memcmp
(
pfni
->
FileName
,
&
szHoo
[
1
],
6
),
"name wrong
\n
"
);
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
0
,
0
);
ok
(
r
==
STATUS_INVALID_PARAMETER
,
"should return invalid parameter
\n
"
);
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
hEvent
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
0
,
0
);
ok
(
r
==
STATUS_INVALID_PARAMETER
,
"should return invalid parameter
\n
"
);
filter
=
FILE_NOTIFY_CHANGE_SIZE
;
iosb
.
Status
=
1
;
iosb
.
Information
=
1
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb
,
NULL
,
0
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should return status pending
\n
"
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
ok
(
iosb
.
Status
==
1
,
"information wrong
\n
"
);
ok
(
iosb
.
Information
==
1
,
"information wrong
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
0
);
ok
(
r
==
STATUS_TIMEOUT
,
"
event shouldn't be ready
\n
"
);
ok
(
r
==
STATUS_TIMEOUT
,
"
should timeout
\n
"
);
r
=
RemoveDirectoryW
(
subdir
);
ok
(
r
==
TRUE
,
"failed to remove directory
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
0
);
ok
(
r
==
WAIT_OBJECT_0
,
"event wasn't ready
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
100
);
ok
(
r
==
WAIT_OBJECT_0
,
"should be ready
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
100
);
ok
(
r
==
WAIT_OBJECT_0
,
"should be ready
\n
"
);
ok
(
iosb
.
Status
==
STATUS_NOTIFY_ENUM_DIR
,
"information wrong
\n
"
);
ok
(
iosb
.
Information
==
0
,
"information wrong
\n
"
);
CloseHandle
(
hdir
);
CloseHandle
(
hEvent
);
r
=
RemoveDirectoryW
(
path
);
ok
(
r
==
FALSE
,
"failed to remove directory
\n
"
);
ok
(
r
==
TRUE
,
"failed to remove directory
\n
"
);
}
static
void
test_ntncdf_async
(
void
)
{
NTSTATUS
r
;
HANDLE
hdir
,
hEvent
;
char
buffer
[
0x1000
];
DWORD
fflags
,
filter
=
0
;
IO_STATUS_BLOCK
iosb
,
iosb2
;
WCHAR
path
[
MAX_PATH
],
subdir
[
MAX_PATH
];
static
const
WCHAR
szBoo
[]
=
{
'\\'
,
'b'
,
'o'
,
'o'
,
0
};
static
const
WCHAR
szHoo
[]
=
{
'\\'
,
'h'
,
'o'
,
'o'
,
0
};
PFILE_NOTIFY_INFORMATION
pfni
;
r
=
GetTempPathW
(
MAX_PATH
,
path
);
ok
(
r
!=
0
,
"temp path failed
\n
"
);
if
(
!
r
)
return
;
lstrcatW
(
path
,
szBoo
);
lstrcpyW
(
subdir
,
path
);
lstrcatW
(
subdir
,
szHoo
);
RemoveDirectoryW
(
subdir
);
RemoveDirectoryW
(
path
);
r
=
CreateDirectoryW
(
path
,
NULL
);
ok
(
r
==
TRUE
,
"failed to create directory
\n
"
);
r
=
pNtNotifyChangeDirectoryFile
(
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
0
,
0
);
ok
(
r
==
STATUS_ACCESS_VIOLATION
,
"should return access violation
\n
"
);
fflags
=
FILE_FLAG_BACKUP_SEMANTICS
|
FILE_FLAG_OVERLAPPED
;
hdir
=
CreateFileW
(
path
,
GENERIC_READ
|
SYNCHRONIZE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
fflags
,
NULL
);
ok
(
hdir
!=
INVALID_HANDLE_VALUE
,
"failed to open directory
\n
"
);
hEvent
=
CreateEvent
(
NULL
,
0
,
0
,
NULL
);
filter
=
FILE_NOTIFY_CHANGE_FILE_NAME
;
filter
|=
FILE_NOTIFY_CHANGE_DIR_NAME
;
filter
|=
FILE_NOTIFY_CHANGE_ATTRIBUTES
;
filter
|=
FILE_NOTIFY_CHANGE_SIZE
;
filter
|=
FILE_NOTIFY_CHANGE_LAST_WRITE
;
filter
|=
FILE_NOTIFY_CHANGE_LAST_ACCESS
;
filter
|=
FILE_NOTIFY_CHANGE_CREATION
;
filter
|=
FILE_NOTIFY_CHANGE_SECURITY
;
iosb
.
Status
=
0x01234567
;
iosb
.
Information
=
0x12345678
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
ok
(
iosb
.
Status
==
0x01234567
,
"status set too soon
\n
"
);
ok
(
iosb
.
Information
==
0x12345678
,
"info set too soon
\n
"
);
r
=
CreateDirectoryW
(
subdir
,
NULL
);
ok
(
r
==
TRUE
,
"failed to create directory
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
100
);
ok
(
r
==
WAIT_OBJECT_0
,
"should be ready
\n
"
);
ok
(
iosb
.
Status
==
STATUS_SUCCESS
,
"status not successful
\n
"
);
ok
(
iosb
.
Information
==
0x12
,
"info not set
\n
"
);
pfni
=
(
PFILE_NOTIFY_INFORMATION
)
buffer
;
ok
(
pfni
->
NextEntryOffset
==
0
,
"offset wrong
\n
"
);
ok
(
pfni
->
Action
==
FILE_ACTION_ADDED
,
"action wrong
\n
"
);
ok
(
pfni
->
FileNameLength
==
6
,
"len wrong
\n
"
);
ok
(
!
memcmp
(
pfni
->
FileName
,
&
szHoo
[
1
],
6
),
"name wrong
\n
"
);
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
r
=
RemoveDirectoryW
(
subdir
);
ok
(
r
==
TRUE
,
"failed to remove directory
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
0
);
ok
(
r
==
WAIT_OBJECT_0
,
"should be ready
\n
"
);
ok
(
iosb
.
Status
==
STATUS_SUCCESS
,
"status not successful
\n
"
);
ok
(
iosb
.
Information
==
0x12
,
"info not set
\n
"
);
ok
(
pfni
->
NextEntryOffset
==
0
,
"offset wrong
\n
"
);
ok
(
pfni
->
Action
==
FILE_ACTION_REMOVED
,
"action wrong
\n
"
);
ok
(
pfni
->
FileNameLength
==
6
,
"len wrong
\n
"
);
ok
(
!
memcmp
(
pfni
->
FileName
,
&
szHoo
[
1
],
6
),
"name wrong
\n
"
);
/* check APCs */
iosb
.
Status
=
0
;
iosb
.
Information
=
0
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb
,
NULL
,
0
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
r
=
CreateDirectoryW
(
subdir
,
NULL
);
ok
(
r
==
TRUE
,
"failed to create directory
\n
"
);
r
=
WaitForSingleObject
(
hdir
,
0
);
ok
(
r
==
WAIT_OBJECT_0
,
"should be ready
\n
"
);
ok
(
iosb
.
Status
==
STATUS_NOTIFY_ENUM_DIR
,
"status not successful
\n
"
);
ok
(
iosb
.
Information
==
0
,
"info not set
\n
"
);
iosb
.
Status
=
0
;
iosb
.
Information
=
0
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
hEvent
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
r
=
RemoveDirectoryW
(
subdir
);
ok
(
r
==
TRUE
,
"failed to remove directory
\n
"
);
r
=
WaitForSingleObject
(
hEvent
,
0
);
ok
(
r
==
WAIT_OBJECT_0
,
"should be ready
\n
"
);
ok
(
iosb
.
Status
==
STATUS_SUCCESS
,
"status not successful
\n
"
);
ok
(
iosb
.
Information
==
0x12
,
"info not set
\n
"
);
iosb
.
Status
=
0x01234567
;
iosb
.
Information
=
0x12345678
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb
,
buffer
,
sizeof
buffer
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
iosb2
.
Status
=
0x01234567
;
iosb2
.
Information
=
0x12345678
;
r
=
pNtNotifyChangeDirectoryFile
(
hdir
,
0
,
NULL
,
NULL
,
&
iosb2
,
buffer
,
sizeof
buffer
,
filter
,
0
);
ok
(
r
==
STATUS_PENDING
,
"should status pending
\n
"
);
ok
(
iosb
.
Status
==
0x01234567
,
"status set too soon
\n
"
);
ok
(
iosb
.
Information
==
0x12345678
,
"info set too soon
\n
"
);
todo_wine
{
r
=
pNtCancelIoFile
(
hdir
,
&
iosb
);
ok
(
r
==
STATUS_SUCCESS
,
"cancel failed
\n
"
);
CloseHandle
(
hdir
);
ok
(
iosb
.
Status
==
STATUS_SUCCESS
,
"status wrong
\n
"
);
ok
(
iosb2
.
Status
==
STATUS_CANCELLED
,
"status wrong
\n
"
);
}
ok
(
iosb
.
Information
==
0
,
"info wrong
\n
"
);
ok
(
iosb2
.
Information
==
0
,
"info wrong
\n
"
);
r
=
RemoveDirectoryW
(
path
);
ok
(
r
==
TRUE
,
"failed to remove directory
\n
"
);
CloseHandle
(
hEvent
);
}
START_TEST
(
change
)
{
HMODULE
hntdll
=
GetModuleHandle
(
"ntdll"
);
pNtNotifyChangeDirectoryFile
=
(
fnNtNotifyChangeDirectoryFile
)
GetProcAddress
(
hntdll
,
"NtNotifyChangeDirectoryFile"
);
pNtCancelIoFile
=
(
fnNtCancelIoFile
)
GetProcAddress
(
hntdll
,
"NtCancelIoFile"
);
if
(
!
pNtNotifyChangeDirectoryFile
)
return
;
if
(
!
pNtCancelIoFile
)
return
;
test_ntncdf
();
test_ntncdf_async
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment