ReactOS 0.4.16-dev-329-g9223134
directory.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include "ntstatus.h"
#include "wine/test.h"
#include "winnls.h"
#include "winternl.h"
Include dependency graph for directory.c:

Go to the source code of this file.

Classes

struct  testfile_s
 

Macros

#define WIN32_NO_STATUS
 

Functions

static NTSTATUS (WINAPI *pNtClose)(PHANDLE)
 
static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING
 
static BOOL (WINAPI *pRtlDosPathNameToNtPathName_U)(LPCWSTR
 
static PWSTR CURDIR *static VOID (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING
 
static LONG (WINAPI *pRtlCompareUnicodeString)(const UNICODE_STRING *
 
static void set_up_attribute_test (const WCHAR *testdir)
 
static void reset_found_files (void)
 
static void tear_down_attribute_test (const WCHAR *testdir)
 
static void tally_test_file (FILE_BOTH_DIRECTORY_INFORMATION *dir_info)
 
static void test_flags_NtQueryDirectoryFile (OBJECT_ATTRIBUTES *attr, const char *testdirA, UNICODE_STRING *mask, BOOLEAN single_entry, BOOLEAN restart_flag)
 
static void test_directory_sort (const WCHAR *testdir)
 
static void test_NtQueryDirectoryFile_classes (HANDLE handle, UNICODE_STRING *mask)
 
static void test_NtQueryDirectoryFile (void)
 
static void set_up_case_test (const char *testdir)
 
static void tear_down_case_test (const char *testdir)
 
static void test_NtQueryDirectoryFile_case (void)
 
static void test_redirection (void)
 
 START_TEST (directory)
 

Variables

static ACCESS_MASK
 
static POBJECT_ATTRIBUTES
 
static PIO_STATUS_BLOCK
 
static ULONG
 
static HANDLE
 
static PIO_APC_ROUTINE
 
static PVOID
 
static FILE_INFORMATION_CLASS
 
static BOOLEAN
 
static PUNICODE_STRING
 
static LONG
 
static LPCSTR
 
static PWSTR CURDIR *static LPCWSTR
 
static DWORD dstlen
 
static DWORD LPDWORD reslen
 
static DWORD LPDWORD LPCSTR src
 
static DWORD LPDWORD LPCSTR DWORD srclen
 
static ULONGold_value
 
static struct testfile_s testfiles []
 
static const int test_dir_count = sizeof(testfiles) / sizeof(testfiles[0])
 
static const int max_test_dir_size = sizeof(testfiles) / sizeof(testfiles[0]) + 5
 
static const WCHAR dummyW [] = {'d','u','m','m','y',0}
 
static const WCHAR dotW [] = {'.',0}
 
static const WCHAR dotdotW [] = {'.','.',0}
 
static const WCHAR backslashW [] = {'\\',0}
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 34 of file directory.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pRtlDosPathNameToNtPathName_U)
static

◆ BOOLEAN()

static BOOLEAN ( WINAPI pRtlCreateUnicodeStringFromAsciiz)
static

◆ LONG()

static LONG ( WINAPI pRtlCompareUnicodeString) const
static

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtClose)
static

◆ reset_found_files()

static void reset_found_files ( void  )
static

Definition at line 115 of file directory.c.

116{
117 int i;
118
119 for (i = 0; i < test_dir_count; i++)
120 testfiles[i].nfound = 0;
121}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static struct testfile_s testfiles[]
static const int test_dir_count
Definition: directory.c:76

Referenced by test_flags_NtQueryDirectoryFile().

◆ set_up_attribute_test()

static void set_up_attribute_test ( const WCHAR testdir)
static

Definition at line 85 of file directory.c.

86{
87 int i;
88 BOOL ret;
89
90 ret = CreateDirectoryW(testdir, NULL);
91 ok(ret, "couldn't create dir %s, error %d\n", wine_dbgstr_w(testdir), GetLastError());
92
93 for (i=0; i < test_dir_count; i++) {
95
96 if (lstrcmpW(testfiles[i].name, dotW) == 0 || lstrcmpW(testfiles[i].name, dotdotW) == 0)
97 continue;
98 lstrcpyW( buf, testdir );
103 ok(ret, "couldn't create dir %s, error %d\n", wine_dbgstr_w(buf), GetLastError());
104 } else {
108 testfiles[i].attr, 0);
109 ok( h != INVALID_HANDLE_VALUE, "failed to create temp file %s\n", wine_dbgstr_w(buf) );
110 CloseHandle(h);
111 }
112 }
113}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#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
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define wine_dbgstr_w
Definition: kernel32.h:34
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define CREATE_ALWAYS
Definition: disk.h:72
static const WCHAR dotdotW[]
Definition: directory.c:81
static const WCHAR dotW[]
Definition: directory.c:80
static const WCHAR backslashW[]
Definition: directory.c:82
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: cookie.c:202
Definition: name.c:39
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_NtQueryDirectoryFile().

◆ set_up_case_test()

static void set_up_case_test ( const char testdir)
static

Definition at line 731 of file directory.c.

732{
733 BOOL ret;
734 char buf[MAX_PATH];
735 HANDLE h;
736
737 ret = CreateDirectoryA(testdir, NULL);
738 ok(ret, "couldn't create dir '%s', error %d\n", testdir, GetLastError());
739
740 sprintf(buf, "%s\\%s", testdir, "TesT");
743 ok(h != INVALID_HANDLE_VALUE, "failed to create temp file '%s'\n", buf);
744 CloseHandle(h);
745}
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
#define sprintf(buf, format,...)
Definition: sprintf.c:55

Referenced by test_NtQueryDirectoryFile_case().

◆ START_TEST()

START_TEST ( directory  )

Definition at line 876 of file directory.c.

877{
878 WCHAR sysdir[MAX_PATH];
879 HMODULE hntdll = GetModuleHandleA("ntdll.dll");
880 if (!hntdll)
881 {
882 skip("not running on NT, skipping test\n");
883 return;
884 }
885
886 pNtClose = (void *)GetProcAddress(hntdll, "NtClose");
887 pNtOpenFile = (void *)GetProcAddress(hntdll, "NtOpenFile");
888 pNtQueryDirectoryFile = (void *)GetProcAddress(hntdll, "NtQueryDirectoryFile");
889 pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile");
890 pNtSetInformationFile = (void *)GetProcAddress(hntdll, "NtSetInformationFile");
891 pRtlCreateUnicodeStringFromAsciiz = (void *)GetProcAddress(hntdll, "RtlCreateUnicodeStringFromAsciiz");
892 pRtlDosPathNameToNtPathName_U = (void *)GetProcAddress(hntdll, "RtlDosPathNameToNtPathName_U");
893 pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
894 pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
895 pRtlCompareUnicodeString = (void *)GetProcAddress(hntdll, "RtlCompareUnicodeString");
896 pRtlMultiByteToUnicodeN = (void *)GetProcAddress(hntdll,"RtlMultiByteToUnicodeN");
897 pRtlWow64EnableFsRedirection = (void *)GetProcAddress(hntdll,"RtlWow64EnableFsRedirection");
898 pRtlWow64EnableFsRedirectionEx = (void *)GetProcAddress(hntdll,"RtlWow64EnableFsRedirectionEx");
899
900 GetSystemDirectoryW( sysdir, MAX_PATH );
901 test_directory_sort( sysdir );
905}
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
static HINSTANCE hntdll
Definition: process.c:66
static void test_NtQueryDirectoryFile_case(void)
Definition: directory.c:759
static void test_NtQueryDirectoryFile(void)
Definition: directory.c:447
static void test_redirection(void)
Definition: directory.c:826
static void test_directory_sort(const WCHAR *testdir)
Definition: directory.c:252

◆ tally_test_file()

static void tally_test_file ( FILE_BOTH_DIRECTORY_INFORMATION dir_info)
static

Definition at line 150 of file directory.c.

151{
152 int i;
153 DWORD attribmask =
155 DWORD attrib = dir_info->FileAttributes & attribmask;
156 WCHAR *nameW = dir_info->FileName;
157 int namelen = dir_info->FileNameLength / sizeof(WCHAR);
158
159 for (i = 0; i < test_dir_count; i++) {
160 int len = lstrlenW(testfiles[i].name);
161 if (namelen != len || memcmp(nameW, testfiles[i].name, len*sizeof(WCHAR)))
162 continue;
163 if (!testfiles[i].attr_done) {
164 ok (attrib == (testfiles[i].attr & attribmask), "file %s: expected %s (%x), got %x (is your linux new enough?)\n", wine_dbgstr_w(testfiles[i].name), testfiles[i].description, testfiles[i].attr, attrib);
165 testfiles[i].attr_done = TRUE;
166 }
167 testfiles[i].nfound++;
168 break;
169 }
170 ok(i < test_dir_count, "unexpected file found %s\n", wine_dbgstr_wn(dir_info->FileName, namelen));
171}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static const WCHAR nameW[]
Definition: main.c:49
#define TRUE
Definition: types.h:120
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint namelen
Definition: glext.h:7232
GLenum GLsizei len
Definition: glext.h:6722
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
#define wine_dbgstr_wn
Definition: testlist.c:2
WCHAR FileName[ANYSIZE_ARRAY]
Definition: winternl.h:573
const char * description
Definition: directx.c:2497

Referenced by test_flags_NtQueryDirectoryFile().

◆ tear_down_attribute_test()

static void tear_down_attribute_test ( const WCHAR testdir)
static

Definition at line 124 of file directory.c.

125{
126 int i;
127
128 for (i = 0; i < test_dir_count; i++) {
129 int ret;
131 if (lstrcmpW(testfiles[i].name, dotW) == 0 || lstrcmpW(testfiles[i].name, dotdotW) == 0)
132 continue;
133 lstrcpyW( buf, testdir );
139 "Failed to rmdir %s, error %d\n", wine_dbgstr_w(buf), GetLastError());
140 } else {
143 "Failed to rm %s, error %d\n", wine_dbgstr_w(buf), GetLastError());
144 }
145 }
146 RemoveDirectoryW(testdir);
147}
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

Referenced by test_NtQueryDirectoryFile().

◆ tear_down_case_test()

static void tear_down_case_test ( const char testdir)
static

Definition at line 747 of file directory.c.

748{
749 int ret;
750 char buf[MAX_PATH];
751
752 sprintf(buf, "%s\\%s", testdir, "TesT");
755 "Failed to rm %s, error %d\n", buf, GetLastError());
756 RemoveDirectoryA(testdir);
757}
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by test_NtQueryDirectoryFile_case().

◆ test_directory_sort()

static void test_directory_sort ( const WCHAR testdir)
static

Definition at line 252 of file directory.c.

253{
255 UNICODE_STRING ntdirname;
257 UINT data_pos, data_len, count;
258 BYTE data[8192];
259 WCHAR prev[MAX_PATH], name[MAX_PATH];
260 UNICODE_STRING prev_str, name_str;
264 int res;
265
266 if (!pRtlDosPathNameToNtPathName_U( testdir, &ntdirname, NULL, NULL ))
267 {
268 ok(0, "RtlDosPathNametoNtPathName_U failed\n");
269 return;
270 }
274 ok(status == STATUS_SUCCESS, "failed to open dir %s\n", wine_dbgstr_w(testdir) );
275
276 U(io).Status = 0xdeadbeef;
277 status = pNtQueryDirectoryFile( handle, NULL, NULL, NULL, &io, data, sizeof(data),
279 ok( status == STATUS_SUCCESS, "failed to query directory; status %x\n", status );
280 ok( U(io).Status == STATUS_SUCCESS, "failed to query directory; status %x\n", U(io).Status );
281 data_len = io.Information;
282 ok( data_len >= sizeof(FILE_BOTH_DIRECTORY_INFORMATION), "not enough data in directory\n" );
283 data_pos = 0;
284 count = 0;
285
286 while (data_pos < data_len)
287 {
288 info = (FILE_BOTH_DIRECTORY_INFORMATION *)(data + data_pos);
289
290 memcpy( name, info->FileName, info->FileNameLength );
291 name[info->FileNameLength / sizeof(WCHAR)] = 0;
292 switch (count)
293 {
294 case 0: /* first entry must be '.' */
295 ok( !lstrcmpW( name, dotW ), "wrong name %s\n", wine_dbgstr_w( name ));
296 break;
297 case 1: /* second entry must be '..' */
298 ok( !lstrcmpW( name, dotdotW ), "wrong name %s\n", wine_dbgstr_w( name ));
299 break;
300 case 2: /* nothing to compare against */
301 break;
302 default:
303 pRtlInitUnicodeString( &prev_str, prev );
304 pRtlInitUnicodeString( &name_str, name );
305 res = pRtlCompareUnicodeString( &prev_str, &name_str, TRUE );
306 ok( res < 0, "wrong result %d %s %s\n", res, wine_dbgstr_w( prev ), wine_dbgstr_w( name ));
307 break;
308 }
309 count++;
310 lstrcpyW( prev, name );
311
312 if (info->NextEntryOffset == 0)
313 {
314 U(io).Status = 0xdeadbeef;
315 status = pNtQueryDirectoryFile( handle, 0, NULL, NULL, &io, data, sizeof(data),
317 ok (U(io).Status == status, "wrong status %x / %x\n", status, U(io).Status);
318 if (status == STATUS_NO_MORE_FILES) break;
319 ok( status == STATUS_SUCCESS, "failed to query directory; status %x\n", status );
320 data_len = io.Information;
321 data_pos = 0;
322 }
323 else data_pos += info->NextEntryOffset;
324 }
325
326 pNtClose( handle );
327 pRtlFreeUnicodeString( &ntdirname );
328}
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define U(x)
Definition: wordpad.c:45
#define FALSE
Definition: types.h:117
#define FILE_SHARE_READ
Definition: compat.h:136
@ FileBothDirectoryInformation
Definition: from_kernel.h:64
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
unsigned int UINT
Definition: ndis.h:50
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST(), and test_NtQueryDirectoryFile().

◆ test_flags_NtQueryDirectoryFile()

static void test_flags_NtQueryDirectoryFile ( OBJECT_ATTRIBUTES attr,
const char testdirA,
UNICODE_STRING mask,
BOOLEAN  single_entry,
BOOLEAN  restart_flag 
)
static

Definition at line 173 of file directory.c.

176{
177 UNICODE_STRING dummy_mask;
178 HANDLE dirh, new_dirh;
180 UINT data_pos, data_size;
181 UINT data_len; /* length of dir data */
182 BYTE data[8192]; /* directory data */
185 int numfiles;
186 int i;
187
189 pRtlInitUnicodeString( &dummy_mask, dummyW );
190
192
193 /* Read the directory and note which files are found */
194 status = pNtOpenFile( &dirh, SYNCHRONIZE | FILE_LIST_DIRECTORY, attr, &io, FILE_SHARE_READ,
196 ok (status == STATUS_SUCCESS, "failed to open dir '%s', ret 0x%x, error %d\n", testdirA, status, GetLastError());
197 if (status != STATUS_SUCCESS) {
198 skip("can't test if we can't open the directory\n");
199 return;
200 }
201
202 U(io).Status = 0xdeadbeef;
203 status = pNtQueryDirectoryFile( dirh, NULL, NULL, NULL, &io, data, data_size,
204 FileBothDirectoryInformation, single_entry, mask, restart_flag );
205 ok (status == STATUS_SUCCESS, "failed to query directory; status %x\n", status);
206 ok (U(io).Status == STATUS_SUCCESS, "failed to query directory; status %x\n", U(io).Status);
207 data_len = io.Information;
208 ok (data_len >= sizeof(FILE_BOTH_DIRECTORY_INFORMATION), "not enough data in directory\n");
209
212 pNtClose(dirh);
213
214 data_pos = 0;
215 numfiles = 0;
216 while ((data_pos < data_len) && (numfiles < max_test_dir_size)) {
217 dir_info = (FILE_BOTH_DIRECTORY_INFORMATION *)(data + data_pos);
218
219 tally_test_file(dir_info);
220
221 if (dir_info->NextEntryOffset == 0) {
222 U(io).Status = 0xdeadbeef;
223 status = pNtQueryDirectoryFile( new_dirh, 0, NULL, NULL, &io, data, data_size,
224 FileBothDirectoryInformation, single_entry, &dummy_mask, FALSE );
225 ok (U(io).Status == status, "wrong status %x / %x\n", status, U(io).Status);
226 if (status == STATUS_NO_MORE_FILES) break;
227 ok (status == STATUS_SUCCESS, "failed to query directory; status %x\n", status);
228 data_len = io.Information;
229 if (data_len < sizeof(FILE_BOTH_DIRECTORY_INFORMATION))
230 break;
231 data_pos = 0;
232 } else {
233 data_pos += dir_info->NextEntryOffset;
234 }
235 numfiles++;
236 }
237 ok(numfiles < max_test_dir_size, "too many loops\n");
238
239 if (mask)
240 for (i = 0; i < test_dir_count; i++)
241 ok(testfiles[i].nfound == (testfiles[i].name == mask->Buffer),
242 "Wrong number %d of %s files found (single_entry=%d,mask=%s)\n",
243 testfiles[i].nfound, testfiles[i].description, single_entry,
244 wine_dbgstr_wn(mask->Buffer, mask->Length/sizeof(WCHAR) ));
245 else
246 for (i = 0; i < test_dir_count; i++)
247 ok(testfiles[i].nfound == 1, "Wrong number %d of %s files found (single_entry=%d,restart=%d)\n",
248 testfiles[i].nfound, testfiles[i].description, single_entry, restart_flag);
249 pNtClose(new_dirh);
250}
#define GetCurrentProcess()
Definition: compat.h:759
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
GLenum GLint GLuint mask
Definition: glext.h:6028
static const WCHAR dummyW[]
Definition: directory.c:79
static void reset_found_files(void)
Definition: directory.c:115
static const int max_test_dir_size
Definition: directory.c:77
static void tally_test_file(FILE_BOTH_DIRECTORY_INFORMATION *dir_info)
Definition: directory.c:150
#define offsetof(TYPE, MEMBER)
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define DUPLICATE_SAME_ACCESS

Referenced by test_NtQueryDirectoryFile().

◆ test_NtQueryDirectoryFile()

static void test_NtQueryDirectoryFile ( void  )
static

Definition at line 447 of file directory.c.

448{
450 UNICODE_STRING ntdirname, mask;
451 char testdirA[MAX_PATH];
452 WCHAR testdirW[MAX_PATH];
453 int i;
455 WCHAR short_name[12];
456 UINT data_size;
457 BYTE data[8192];
461 const WCHAR *filename = fbdi->FileName;
463 HANDLE dirh;
464
465 /* Clean up from prior aborted run, if any, then set up test files */
466 ok(GetTempPathA(MAX_PATH, testdirA), "couldn't get temp dir\n");
467 strcat(testdirA, "NtQueryDirectoryFile.tmp");
468 pRtlMultiByteToUnicodeN(testdirW, sizeof(testdirW), NULL, testdirA, strlen(testdirA)+1);
469 tear_down_attribute_test(testdirW);
470 set_up_attribute_test(testdirW);
471
472 if (!pRtlDosPathNameToNtPathName_U(testdirW, &ntdirname, NULL, NULL))
473 {
474 ok(0, "RtlDosPathNametoNtPathName_U failed\n");
475 goto done;
476 }
478
483
484 for (i = 0; i < test_dir_count; i++)
485 {
486 if (testfiles[i].name[0] == '.') continue; /* . and .. as masks are broken on Windows */
487 mask.Buffer = testfiles[i].name;
488 mask.Length = mask.MaximumLength = lstrlenW(testfiles[i].name) * sizeof(WCHAR);
493 }
494
495 /* short path passed as mask */
496 status = pNtOpenFile(&dirh, SYNCHRONIZE | FILE_LIST_DIRECTORY, &attr, &io, FILE_SHARE_READ,
498 ok(status == STATUS_SUCCESS, "failed to open dir '%s'\n", testdirA);
499 if (status != STATUS_SUCCESS) {
500 skip("can't test if we can't open the directory\n");
501 return;
502 }
503 status = pNtQueryInformationFile( dirh, &io, &pos_info, sizeof(pos_info), FilePositionInformation );
504 ok( status == STATUS_SUCCESS, "NtQueryInformationFile failed %x\n", status );
505 ok( pos_info.CurrentByteOffset.QuadPart == 0, "wrong pos %s\n",
507
508 pos_info.CurrentByteOffset.QuadPart = 0xbeef;
509 status = pNtSetInformationFile( dirh, &io, &pos_info, sizeof(pos_info), FilePositionInformation );
510 ok( status == STATUS_SUCCESS, "NtQueryInformationFile failed %x\n", status );
511
512 status = pNtQueryInformationFile( dirh, &io, &pos_info, sizeof(pos_info), FilePositionInformation );
513 ok( status == STATUS_SUCCESS, "NtQueryInformationFile failed %x\n", status );
514 ok( pos_info.CurrentByteOffset.QuadPart == 0xbeef, "wrong pos %s\n",
516
517 mask.Buffer = testfiles[0].name;
518 mask.Length = mask.MaximumLength = lstrlenW(testfiles[0].name) * sizeof(WCHAR);
520 U(io).Status = 0xdeadbeef;
521 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
523 ok(status == STATUS_SUCCESS, "failed to query directory; status %x\n", status);
524 ok(U(io).Status == STATUS_SUCCESS, "failed to query directory; status %x\n", U(io).Status);
525 ok(fbdi->ShortName[0], "ShortName is empty\n");
526
527 status = pNtQueryInformationFile( dirh, &io, &pos_info, sizeof(pos_info), FilePositionInformation );
528 ok( status == STATUS_SUCCESS, "NtQueryInformationFile failed %x\n", status );
529 ok( pos_info.CurrentByteOffset.QuadPart == 0xbeef, "wrong pos %s\n",
531
532 mask.Length = mask.MaximumLength = fbdi->ShortNameLength;
533 memcpy(short_name, fbdi->ShortName, mask.Length);
534 mask.Buffer = short_name;
535 U(io).Status = 0xdeadbeef;
536 U(io).Information = 0xdeadbeef;
537 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
539 ok(status == STATUS_SUCCESS, "failed to query directory status %x\n", status);
540 ok(U(io).Status == STATUS_SUCCESS, "failed to query directory status %x\n", U(io).Status);
542 "wrong info %lx\n", U(io).Information);
543 ok(fbdi->FileNameLength == lstrlenW(testfiles[0].name)*sizeof(WCHAR) &&
544 !memcmp(fbdi->FileName, testfiles[0].name, fbdi->FileNameLength),
545 "incorrect long file name: %s\n", wine_dbgstr_wn(fbdi->FileName,
546 fbdi->FileNameLength/sizeof(WCHAR)));
547
548 status = pNtQueryInformationFile( dirh, &io, &pos_info, sizeof(pos_info), FilePositionInformation );
549 ok( status == STATUS_SUCCESS, "NtQueryInformationFile failed %x\n", status );
550 ok( pos_info.CurrentByteOffset.QuadPart == 0xbeef, "wrong pos %s\n",
552
553 /* tests with short buffer */
554 memset( data, 0x55, data_size );
555 U(io).Status = 0xdeadbeef;
556 U(io).Information = 0xdeadbeef;
558 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
560 ok( status == STATUS_BUFFER_OVERFLOW, "wrong status %x\n", status );
561 ok( U(io).Status == STATUS_BUFFER_OVERFLOW, "wrong status %x\n", U(io).Status );
562 ok( U(io).Information == data_size || broken( U(io).Information == 0),
563 "wrong info %lx\n", U(io).Information );
564 ok( fbdi->NextEntryOffset == 0, "wrong offset %x\n", fbdi->NextEntryOffset );
565 ok( fbdi->FileNameLength == lstrlenW(testfiles[0].name) * sizeof(WCHAR),
566 "wrong length %x\n", fbdi->FileNameLength );
567 ok( filename[0] == testfiles[0].name[0], "incorrect long file name: %s\n",
568 wine_dbgstr_wn(fbdi->FileName, fbdi->FileNameLength/sizeof(WCHAR)));
569 ok( filename[1] == 0x5555, "incorrect long file name: %s\n",
570 wine_dbgstr_wn(fbdi->FileName, fbdi->FileNameLength/sizeof(WCHAR)));
571
573
574 /* mask may or may not be ignored when restarting the search */
575 pRtlInitUnicodeString( &mask, dummyW );
576 U(io).Status = 0xdeadbeef;
578 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
580 ok( status == STATUS_SUCCESS || status == STATUS_NO_MORE_FILES, "wrong status %x\n", status );
581 ok( U(io).Status == status, "wrong status %x / %x\n", U(io).Status, status );
582 if (!status)
583 ok( fbdi->FileNameLength == lstrlenW(testfiles[0].name)*sizeof(WCHAR) &&
584 !memcmp(fbdi->FileName, testfiles[0].name, fbdi->FileNameLength),
585 "incorrect long file name: %s\n",
586 wine_dbgstr_wn(fbdi->FileName, fbdi->FileNameLength/sizeof(WCHAR)));
587
588 pNtClose(dirh);
589
590 status = pNtOpenFile(&dirh, SYNCHRONIZE | FILE_LIST_DIRECTORY, &attr, &io, FILE_SHARE_READ,
592 ok(status == STATUS_SUCCESS, "failed to open dir '%s'\n", testdirA);
593
594 memset( data, 0x55, data_size );
595 data_size = sizeof(data);
596 U(io).Status = 0xdeadbeef;
597 U(io).Information = 0xdeadbeef;
598 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
600 ok(status == STATUS_SUCCESS, "wrong status %x\n", status);
601 ok(U(io).Status == STATUS_SUCCESS, "wrong status %x\n", U(io).Status);
602 ok(U(io).Information > 0 && U(io).Information < data_size, "wrong info %lx\n", U(io).Information);
604 "wrong offset %x\n", fbdi->NextEntryOffset );
605 ok( fbdi->FileNameLength == sizeof(WCHAR), "wrong length %x\n", fbdi->FileNameLength );
606 ok( fbdi->FileName[0] == '.', "incorrect long file name: %s\n",
607 wine_dbgstr_wn(fbdi->FileName, fbdi->FileNameLength/sizeof(WCHAR)));
609 ok( next->NextEntryOffset == ((offsetof( FILE_BOTH_DIRECTORY_INFORMATION, FileName[2] ) + 7) & ~7),
610 "wrong offset %x\n", next->NextEntryOffset );
611 ok( next->FileNameLength == 2 * sizeof(WCHAR), "wrong length %x\n", next->FileNameLength );
612 filename = next->FileName;
613 ok( filename[0] == '.' && filename[1] == '.', "incorrect long file name: %s\n",
614 wine_dbgstr_wn(next->FileName, next->FileNameLength/sizeof(WCHAR)));
615
617 memset( data, 0x55, data_size );
618 U(io).Status = 0xdeadbeef;
619 U(io).Information = 0xdeadbeef;
620 status = pNtQueryDirectoryFile( dirh, 0, NULL, NULL, &io, data, data_size,
622 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
623 ok( U(io).Status == STATUS_SUCCESS, "wrong status %x\n", U(io).Status );
625 "wrong info %lx\n", U(io).Information );
626 ok( fbdi->NextEntryOffset == 0, "wrong offset %x\n", fbdi->NextEntryOffset );
627 ok( fbdi->FileNameLength == sizeof(WCHAR), "wrong length %x\n", fbdi->FileNameLength );
628 ok( fbdi->FileName[0] == '.', "incorrect long file name: %s\n",
629 wine_dbgstr_wn(fbdi->FileName, fbdi->FileNameLength/sizeof(WCHAR)));
631 ok( next->NextEntryOffset == 0x55555555, "wrong offset %x\n", next->NextEntryOffset );
632
634 memset( data, 0x55, data_size );
635 U(io).Status = 0xdeadbeef;
636 U(io).Information = 0xdeadbeef;
637 status = pNtQueryDirectoryFile( dirh, 0, NULL, NULL, &io, data, data_size,
639 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
640 ok( U(io).Status == STATUS_SUCCESS, "wrong status %x\n", U(io).Status );
642 "wrong info %lx\n", U(io).Information );
643 ok( fbdi->NextEntryOffset == 0, "wrong offset %x\n", fbdi->NextEntryOffset );
644
645 data_size = ((offsetof( FILE_BOTH_DIRECTORY_INFORMATION, FileName[1] ) + 7) & ~7) +
647 memset( data, 0x55, data_size );
648 U(io).Status = 0xdeadbeef;
649 U(io).Information = 0xdeadbeef;
650 status = pNtQueryDirectoryFile( dirh, 0, NULL, NULL, &io, data, data_size,
652 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
653 ok( U(io).Status == STATUS_SUCCESS, "wrong status %x\n", U(io).Status );
654 ok( U(io).Information == data_size, "wrong info %lx / %x\n", U(io).Information, data_size );
656 "wrong offset %x\n", fbdi->NextEntryOffset );
657 ok( fbdi->FileNameLength == sizeof(WCHAR), "wrong length %x\n", fbdi->FileNameLength );
658 ok( fbdi->FileName[0] == '.', "incorrect long file name: %s\n",
659 wine_dbgstr_wn(fbdi->FileName, fbdi->FileNameLength/sizeof(WCHAR)));
661 ok( next->NextEntryOffset == 0, "wrong offset %x\n", next->NextEntryOffset );
662 ok( next->FileNameLength == 2 * sizeof(WCHAR), "wrong length %x\n", next->FileNameLength );
663 filename = next->FileName;
664 ok( filename[0] == '.' && filename[1] == '.', "incorrect long file name: %s\n",
665 wine_dbgstr_wn(next->FileName, next->FileNameLength/sizeof(WCHAR)));
666
667 data_size = ((offsetof( FILE_NAMES_INFORMATION, FileName[1] ) + 7) & ~7) +
669 memset( data, 0x55, data_size );
670 U(io).Status = 0xdeadbeef;
671 U(io).Information = 0xdeadbeef;
672 status = pNtQueryDirectoryFile( dirh, 0, NULL, NULL, &io, data, data_size,
674 ok( status == STATUS_SUCCESS, "wrong status %x\n", status );
675 ok( U(io).Status == STATUS_SUCCESS, "wrong status %x\n", U(io).Status );
676 ok( U(io).Information == data_size, "wrong info %lx / %x\n", U(io).Information, data_size );
678 ok( names->NextEntryOffset == ((offsetof( FILE_NAMES_INFORMATION, FileName[1] ) + 7) & ~7),
679 "wrong offset %x\n", names->NextEntryOffset );
680 ok( names->FileNameLength == sizeof(WCHAR), "wrong length %x\n", names->FileNameLength );
681 ok( names->FileName[0] == '.', "incorrect long file name: %s\n",
682 wine_dbgstr_wn(names->FileName, names->FileNameLength/sizeof(WCHAR)));
683 names = (FILE_NAMES_INFORMATION *)(data + names->NextEntryOffset);
684 ok( names->NextEntryOffset == 0, "wrong offset %x\n", names->NextEntryOffset );
685 ok( names->FileNameLength == 2 * sizeof(WCHAR), "wrong length %x\n", names->FileNameLength );
686 filename = names->FileName;
687 ok( filename[0] == '.' && filename[1] == '.', "incorrect long file name: %s\n",
688 wine_dbgstr_wn(names->FileName, names->FileNameLength/sizeof(WCHAR)));
689
690 pNtClose(dirh);
691
692 /* create new handle to change mask */
693 status = pNtOpenFile(&dirh, SYNCHRONIZE | FILE_LIST_DIRECTORY, &attr, &io, FILE_SHARE_READ,
695 ok(status == STATUS_SUCCESS, "failed to open dir '%s'\n", testdirA);
696
697 pRtlInitUnicodeString( &mask, dummyW );
698 U(io).Status = 0xdeadbeef;
699 data_size = sizeof(data);
700 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
702 ok(status == STATUS_NO_SUCH_FILE, "wrong status %x\n", status);
703 ok(U(io).Status == 0xdeadbeef, "wrong status %x\n", U(io).Status);
704
705 U(io).Status = 0xdeadbeef;
706 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
708 ok(status == STATUS_NO_MORE_FILES, "wrong status %x\n", status);
709 ok(U(io).Status == STATUS_NO_MORE_FILES, "wrong status %x\n", U(io).Status);
710
711 U(io).Status = 0xdeadbeef;
712 status = pNtQueryDirectoryFile(dirh, 0, NULL, NULL, &io, data, data_size,
714 ok(status == STATUS_NO_MORE_FILES, "wrong status %x\n", status);
715 ok(U(io).Status == STATUS_NO_MORE_FILES, "wrong status %x\n", U(io).Status);
716
717 pNtClose(dirh);
718
719 U(io).Status = 0xdeadbeef;
720 status = pNtQueryDirectoryFile( (HANDLE)0xbeef, 0, NULL, NULL, &io, data, data_size,
722 ok(status == STATUS_INVALID_HANDLE, "wrong status %x\n", status);
723 ok(U(io).Status == 0xdeadbeef, "wrong status %x\n", U(io).Status);
724
725done:
726 test_directory_sort( testdirW );
727 tear_down_attribute_test( testdirW );
728 pRtlFreeUnicodeString(&ntdirname);
729}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define broken(x)
Definition: atltest.h:178
const WCHAR * short_name
Definition: reg.c:29
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileNamesInformation
Definition: from_kernel.h:73
GLuint GLuint * names
Definition: glext.h:11545
const char * filename
Definition: ioapi.h:137
static void tear_down_attribute_test(const WCHAR *testdir)
Definition: directory.c:124
static void test_NtQueryDirectoryFile_classes(HANDLE handle, UNICODE_STRING *mask)
Definition: directory.c:330
static void set_up_attribute_test(const WCHAR *testdir)
Definition: directory.c:85
static void test_flags_NtQueryDirectoryFile(OBJECT_ATTRIBUTES *attr, const char *testdirA, UNICODE_STRING *mask, BOOLEAN single_entry, BOOLEAN restart_flag)
Definition: directory.c:173
static unsigned __int64 next
Definition: rand_nt.c:6
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
#define STATUS_NO_SUCH_FILE
Definition: udferr_usr.h:137
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by START_TEST().

◆ test_NtQueryDirectoryFile_case()

static void test_NtQueryDirectoryFile_case ( void  )
static

Definition at line 759 of file directory.c.

760{
761 static const char testfile[] = "TesT";
762 static const WCHAR testfile_w[] = {'T','e','s','T'};
763 static int testfile_len = sizeof(testfile) - 1;
764 static WCHAR testmask[] = {'t','e','s','t'};
766 UNICODE_STRING ntdirname;
767 char testdir[MAX_PATH];
768 WCHAR testdir_w[MAX_PATH];
769 HANDLE dirh;
772 UINT data_size, data_len;
773 BYTE data[8192];
776 WCHAR *name;
777 ULONG name_len;
778
779 /* Clean up from prior aborted run, if any, then set up test files */
780 ok(GetTempPathA(MAX_PATH, testdir), "couldn't get temp dir\n");
781 strcat(testdir, "case.tmp");
782 tear_down_case_test(testdir);
783 set_up_case_test(testdir);
784
785 pRtlMultiByteToUnicodeN(testdir_w, sizeof(testdir_w), NULL, testdir, strlen(testdir) + 1);
786 if (!pRtlDosPathNameToNtPathName_U(testdir_w, &ntdirname, NULL, NULL))
787 {
788 ok(0, "RtlDosPathNametoNtPathName_U failed\n");
789 goto done;
790 }
792
794
795 status = pNtOpenFile(&dirh, SYNCHRONIZE | FILE_LIST_DIRECTORY, &attr, &io, FILE_SHARE_READ,
797 ok (status == STATUS_SUCCESS, "failed to open dir '%s', ret 0x%x, error %d\n", testdir, status, GetLastError());
798 if (status != STATUS_SUCCESS)
799 {
800 skip("can't test if we can't open the directory\n");
801 return;
802 }
803
804 mask.Buffer = testmask;
805 mask.Length = mask.MaximumLength = sizeof(testmask);
806 pNtQueryDirectoryFile(dirh, NULL, NULL, NULL, &io, data, data_size,
808 ok(U(io).Status == STATUS_SUCCESS, "failed to query directory; status %x\n", U(io).Status);
809 data_len = io.Information;
810 ok(data_len >= sizeof(FILE_BOTH_DIRECTORY_INFORMATION), "not enough data in directory\n");
811
812 name = dir_info->FileName;
813 name_len = dir_info->FileNameLength / sizeof(WCHAR);
814
815 ok(name_len == testfile_len, "unexpected filename length %u\n", name_len);
816 ok(!memcmp(name, testfile_w, testfile_len * sizeof(WCHAR)), "unexpected filename %s\n",
817 wine_dbgstr_wn(name, name_len));
818
819 pNtClose(dirh);
820
821done:
822 tear_down_case_test(testdir);
823 pRtlFreeUnicodeString(&ntdirname);
824}
static void tear_down_case_test(const char *testdir)
Definition: directory.c:747
static void set_up_case_test(const char *testdir)
Definition: directory.c:731
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_NtQueryDirectoryFile_classes()

static void test_NtQueryDirectoryFile_classes ( HANDLE  handle,
UNICODE_STRING mask 
)
static

Definition at line 330 of file directory.c.

331{
333 UINT data_size;
334 ULONG data[256];
336 int class;
337
338 for (class = 0; class < FileMaximumInformation; class++)
339 {
340 U(io).Status = 0xdeadbeef;
341 U(io).Information = 0xdeadbeef;
342 data_size = 0;
343 memset( data, 0x55, sizeof(data) );
344
345 status = pNtQueryDirectoryFile( handle, 0, NULL, NULL, &io, data, data_size,
346 class, FALSE, mask, TRUE );
347 ok( U(io).Status == 0xdeadbeef, "%u: wrong status %x\n", class, U(io).Status );
348 ok( U(io).Information == 0xdeadbeef, "%u: wrong info %lx\n", class, U(io).Information );
349 ok(data[0] == 0x55555555, "%u: wrong offset %x\n", class, data[0] );
350
351 switch (class)
352 {
357 /* fall through */
367 ok( status == STATUS_INFO_LENGTH_MISMATCH, "%u: wrong status %x\n", class, status );
368 break;
369 default:
371 "%u: wrong status %x\n", class, status );
372 continue;
373 }
374
375 for (data_size = 1; data_size < sizeof(data); data_size++)
376 {
377 status = pNtQueryDirectoryFile( handle, 0, NULL, NULL, &io, data, data_size,
378 class, FALSE, mask, TRUE );
380 {
381 ok( U(io).Status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, U(io).Status );
382 ok( U(io).Information == data_size, "%u: wrong info %lx\n", class, U(io).Information );
383 ok(data[0] == 0, "%u: wrong offset %x\n", class, data[0] );
384 }
385 else
386 {
387 ok( U(io).Status == 0xdeadbeef, "%u: wrong status %x\n", class, U(io).Status );
388 ok( U(io).Information == 0xdeadbeef, "%u: wrong info %lx\n", class, U(io).Information );
389 ok(data[0] == 0x55555555, "%u: wrong offset %x\n", class, data[0] );
390 }
392 }
393
394 switch (class)
395 {
397 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
398 ok( data_size == ((offsetof( FILE_DIRECTORY_INFORMATION, FileName[1] ) + 7) & ~7),
399 "%u: wrong size %u\n", class, data_size );
400 break;
402 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
403 ok( data_size == ((offsetof( FILE_FULL_DIRECTORY_INFORMATION, FileName[1] ) + 7) & ~7),
404 "%u: wrong size %u\n", class, data_size );
405 break;
407 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
408 ok( data_size == ((offsetof( FILE_BOTH_DIRECTORY_INFORMATION, FileName[1] ) + 7) & ~7),
409 "%u: wrong size %u\n", class, data_size );
410 break;
412 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
413 ok( data_size == ((offsetof( FILE_NAMES_INFORMATION, FileName[1] ) + 7) & ~7),
414 "%u: wrong size %u\n", class, data_size );
415 break;
417 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
418 ok( data_size == ((offsetof( FILE_ID_BOTH_DIRECTORY_INFORMATION, FileName[1] ) + 7) & ~7),
419 "%u: wrong size %u\n", class, data_size );
420 break;
422 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
423 ok( data_size == ((offsetof( FILE_ID_FULL_DIRECTORY_INFORMATION, FileName[1] ) + 7) & ~7),
424 "%u: wrong size %u\n", class, data_size );
425 break;
427 ok( status == STATUS_BUFFER_OVERFLOW, "%u: wrong status %x\n", class, status );
428 ok( data_size == ((offsetof( FILE_ID_GLOBAL_TX_DIR_INFORMATION, FileName[1] ) + 7) & ~7),
429 "%u: wrong size %u\n", class, data_size );
430 break;
432 ok( status == STATUS_INVALID_INFO_CLASS, "%u: wrong status %x\n", class, status );
433 ok( data_size == sizeof(FILE_OBJECTID_INFORMATION), "%u: wrong size %u\n", class, data_size );
434 break;
436 ok( status == STATUS_INVALID_INFO_CLASS, "%u: wrong status %x\n", class, status );
437 ok( data_size == sizeof(FILE_QUOTA_INFORMATION), "%u: wrong size %u\n", class, data_size );
438 break;
440 ok( status == STATUS_INVALID_INFO_CLASS, "%u: wrong status %x\n", class, status );
441 ok( data_size == sizeof(FILE_REPARSE_POINT_INFORMATION), "%u: wrong size %u\n", class, data_size );
442 break;
443 }
444 }
445}
#define FileIdExtdDirectoryInformation
Definition: dirctrl.c:24
#define FileIdExtdBothDirectoryInformation
Definition: dirctrl.c:25
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
@ FileMaximumInformation
Definition: from_kernel.h:112
@ FileIdGlobalTxDirectoryInformation
Definition: from_kernel.h:111
@ FileQuotaInformation
Definition: from_kernel.h:93
@ FileDirectoryInformation
Definition: from_kernel.h:62
@ FileReparsePointInformation
Definition: from_kernel.h:94
@ FileObjectIdInformation
Definition: from_kernel.h:90
@ FileIdBothDirectoryInformation
Definition: from_kernel.h:98
@ FileFullDirectoryInformation
Definition: from_kernel.h:63
@ FileIdFullDirectoryInformation
Definition: from_kernel.h:99
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133

Referenced by test_NtQueryDirectoryFile().

◆ test_redirection()

static void test_redirection ( void  )
static

Definition at line 826 of file directory.c.

827{
828 ULONG old, cur;
830
831 if (!pRtlWow64EnableFsRedirection || !pRtlWow64EnableFsRedirectionEx)
832 {
833 skip( "Wow64 redirection not supported\n" );
834 return;
835 }
836 status = pRtlWow64EnableFsRedirectionEx( FALSE, &old );
838 {
839 skip( "Wow64 redirection not supported\n" );
840 return;
841 }
842 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
843
844 status = pRtlWow64EnableFsRedirectionEx( FALSE, &cur );
845 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
846 ok( !cur, "RtlWow64EnableFsRedirectionEx got %u\n", cur );
847
848 status = pRtlWow64EnableFsRedirectionEx( TRUE, &cur );
849 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
850 status = pRtlWow64EnableFsRedirectionEx( TRUE, &cur );
851 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
852 ok( cur == 1, "RtlWow64EnableFsRedirectionEx got %u\n", cur );
853
854 status = pRtlWow64EnableFsRedirection( TRUE );
855 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
856 status = pRtlWow64EnableFsRedirectionEx( TRUE, &cur );
857 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
858 ok( !cur, "RtlWow64EnableFsRedirectionEx got %u\n", cur );
859
860 status = pRtlWow64EnableFsRedirectionEx( TRUE, NULL );
861 ok( status == STATUS_ACCESS_VIOLATION, "RtlWow64EnableFsRedirectionEx failed with status %x\n", status );
862 status = pRtlWow64EnableFsRedirectionEx( TRUE, (void*)1 );
863 ok( status == STATUS_ACCESS_VIOLATION, "RtlWow64EnableFsRedirectionEx failed with status %x\n", status );
864 status = pRtlWow64EnableFsRedirectionEx( TRUE, (void*)0xDEADBEEF );
865 ok( status == STATUS_ACCESS_VIOLATION, "RtlWow64EnableFsRedirectionEx failed with status %x\n", status );
866
867 status = pRtlWow64EnableFsRedirection( FALSE );
868 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
869 status = pRtlWow64EnableFsRedirectionEx( FALSE, &cur );
870 ok( !status, "RtlWow64EnableFsRedirectionEx failed status %x\n", status );
871 ok( cur == 1, "RtlWow64EnableFsRedirectionEx got %u\n", cur );
872
873 pRtlWow64EnableFsRedirectionEx( old, &cur );
874}
FxCollectionEntry * cur
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242

Referenced by START_TEST().

◆ VOID()

static PWSTR CURDIR *static VOID ( WINAPI pRtlInitUnicodeString)
static

Variable Documentation

◆ ACCESS_MASK

Definition at line 41 of file directory.c.

◆ backslashW

const WCHAR backslashW[] = {'\\',0}
static

Definition at line 82 of file directory.c.

Referenced by set_up_attribute_test(), and tear_down_attribute_test().

◆ BOOLEAN

Definition at line 43 of file directory.c.

◆ dotdotW

◆ dotW

◆ dstlen

◆ dummyW

◆ FILE_INFORMATION_CLASS

Definition at line 43 of file directory.c.

◆ HANDLE

Definition at line 42 of file directory.c.

◆ LONG

Definition at line 44 of file directory.c.

◆ LPCSTR

Definition at line 46 of file directory.c.

◆ LPCWSTR

PWSTR CURDIR *static LPCWSTR

Definition at line 48 of file directory.c.

◆ max_test_dir_size

const int max_test_dir_size = sizeof(testfiles) / sizeof(testfiles[0]) + 5
static

Definition at line 77 of file directory.c.

Referenced by test_flags_NtQueryDirectoryFile().

◆ old_value

◆ PIO_APC_ROUTINE

PIO_APC_ROUTINE

Definition at line 42 of file directory.c.

◆ PIO_STATUS_BLOCK

Definition at line 41 of file directory.c.

◆ POBJECT_ATTRIBUTES

Definition at line 41 of file directory.c.

◆ PUNICODE_STRING

Definition at line 43 of file directory.c.

◆ PVOID

Definition at line 42 of file directory.c.

◆ reslen

◆ src

Definition at line 52 of file directory.c.

◆ srclen

◆ test_dir_count

◆ testfiles

struct testfile_s testfiles[]
static
Initial value:
= {
{ 0, FILE_ATTRIBUTE_NORMAL, {'l','o','n','g','f','i','l','e','n','a','m','e','.','t','m','p'}, "normal" },
{ 0, FILE_ATTRIBUTE_NORMAL, {'n','.','t','m','p',}, "normal" },
{ 0, FILE_ATTRIBUTE_HIDDEN, {'h','.','t','m','p',}, "hidden" },
{ 0, FILE_ATTRIBUTE_SYSTEM, {'s','.','t','m','p',}, "system" },
{ 0, FILE_ATTRIBUTE_DIRECTORY, {'d','.','t','m','p',}, "directory" },
{ 0, FILE_ATTRIBUTE_NORMAL, {0xe9,'a','.','t','m','p'}, "normal" },
{ 0, FILE_ATTRIBUTE_NORMAL, {0xc9,'b','.','t','m','p'}, "normal" },
{ 0, FILE_ATTRIBUTE_NORMAL, {'e','a','.','t','m','p'}, "normal" },
{ 0, FILE_ATTRIBUTE_DIRECTORY, {'.'}, ". directory" },
{ 0, FILE_ATTRIBUTE_DIRECTORY, {'.','.'}, ".. directory" }
}

Referenced by reset_found_files(), set_up_attribute_test(), tally_test_file(), tear_down_attribute_test(), test_flags_NtQueryDirectoryFile(), and test_NtQueryDirectoryFile().

◆ ULONG

Definition at line 41 of file directory.c.