mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-31 12:08:41 -05:00 
			
		
		
		
	tst: winfsp-tests: HookCreateFileW
This commit is contained in:
		| @@ -186,6 +186,7 @@ | |||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\eventlog-test.c" /> |     <ClCompile Include="..\..\..\tst\winfsp-tests\eventlog-test.c" /> | ||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\flush-test.c" /> |     <ClCompile Include="..\..\..\tst\winfsp-tests\flush-test.c" /> | ||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\fuse-opt-test.c" /> |     <ClCompile Include="..\..\..\tst\winfsp-tests\fuse-opt-test.c" /> | ||||||
|  |     <ClCompile Include="..\..\..\tst\winfsp-tests\hook.c" /> | ||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\info-test.c" /> |     <ClCompile Include="..\..\..\tst\winfsp-tests\info-test.c" /> | ||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\lock-test.c" /> |     <ClCompile Include="..\..\..\tst\winfsp-tests\lock-test.c" /> | ||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\memfs-test.c" /> |     <ClCompile Include="..\..\..\tst\winfsp-tests\memfs-test.c" /> | ||||||
| @@ -201,6 +202,7 @@ | |||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\..\ext\tlib\testsuite.h" /> |     <ClInclude Include="..\..\..\ext\tlib\testsuite.h" /> | ||||||
|     <ClInclude Include="..\..\..\tst\memfs\memfs.h" /> |     <ClInclude Include="..\..\..\tst\memfs\memfs.h" /> | ||||||
|  |     <ClInclude Include="..\..\..\tst\winfsp-tests\winfsp-tests.h" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ProjectReference Include="..\winfsp_dll.vcxproj"> |     <ProjectReference Include="..\winfsp_dll.vcxproj"> | ||||||
|   | |||||||
| @@ -64,6 +64,9 @@ | |||||||
|     <ClCompile Include="..\..\..\tst\winfsp-tests\reparse-test.c"> |     <ClCompile Include="..\..\..\tst\winfsp-tests\reparse-test.c"> | ||||||
|       <Filter>Source</Filter> |       <Filter>Source</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\..\tst\winfsp-tests\hook.c"> | ||||||
|  |       <Filter>Source</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\..\ext\tlib\testsuite.h"> |     <ClInclude Include="..\..\..\ext\tlib\testsuite.h"> | ||||||
| @@ -72,5 +75,8 @@ | |||||||
|     <ClInclude Include="..\..\..\tst\memfs\memfs.h"> |     <ClInclude Include="..\..\..\tst\memfs\memfs.h"> | ||||||
|       <Filter>Source</Filter> |       <Filter>Source</Filter> | ||||||
|     </ClInclude> |     </ClInclude> | ||||||
|  |     <ClInclude Include="..\..\..\tst\winfsp-tests\winfsp-tests.h"> | ||||||
|  |       <Filter>Source</Filter> | ||||||
|  |     </ClInclude> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| </Project> | </Project> | ||||||
| @@ -4,13 +4,7 @@ | |||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start(ULONG Flags); | #include "winfsp-tests.h" | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| void create_dotest(ULONG Flags, PWSTR Prefix) | void create_dotest(ULONG Flags, PWSTR Prefix) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -5,14 +5,7 @@ | |||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| static void querydir_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout, ULONG SleepTimeout) | static void querydir_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout, ULONG SleepTimeout) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| #include <winfsp/winfsp.h> | #include <winfsp/winfsp.h> | ||||||
| #include <tlib/testsuite.h> | #include <tlib/testsuite.h> | ||||||
|  |  | ||||||
|  | #include "winfsp-tests.h" | ||||||
|  |  | ||||||
| void eventlog_test(void) | void eventlog_test(void) | ||||||
| { | { | ||||||
|     /* this is not a real test! */ |     /* this is not a real test! */ | ||||||
|   | |||||||
| @@ -5,14 +5,7 @@ | |||||||
| #include <VersionHelpers.h> | #include <VersionHelpers.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| static void flush_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags, | static void flush_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags, | ||||||
|     BOOLEAN FlushVolume) |     BOOLEAN FlushVolume) | ||||||
|   | |||||||
| @@ -3,6 +3,8 @@ | |||||||
| #include <stddef.h> | #include <stddef.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
|  | #include "winfsp-tests.h" | ||||||
|  |  | ||||||
| struct data | struct data | ||||||
| { | { | ||||||
|     int fortytwo; |     int fortytwo; | ||||||
|   | |||||||
							
								
								
									
										34
									
								
								tst/winfsp-tests/hook.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								tst/winfsp-tests/hook.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | #include <winfsp/winfsp.h> | ||||||
|  |  | ||||||
|  | HANDLE HookCreateFileW( | ||||||
|  |     LPCWSTR lpFileName, | ||||||
|  |     DWORD dwDesiredAccess, | ||||||
|  |     DWORD dwShareMode, | ||||||
|  |     LPSECURITY_ATTRIBUTES lpSecurityAttributes, | ||||||
|  |     DWORD dwCreationDisposition, | ||||||
|  |     DWORD dwFlagsAndAttributes, | ||||||
|  |     HANDLE hTemplateFile) | ||||||
|  | { | ||||||
|  |     HANDLE h = CreateFileW( | ||||||
|  |         lpFileName, | ||||||
|  |         dwDesiredAccess, | ||||||
|  |         dwShareMode, | ||||||
|  |         lpSecurityAttributes, | ||||||
|  |         dwCreationDisposition, | ||||||
|  |         dwFlagsAndAttributes, | ||||||
|  |         hTemplateFile); | ||||||
|  |  | ||||||
|  |     DWORD LastError = GetLastError(); | ||||||
|  |     FspDebugLog("CreateFileW(\"%S\", %#lx, %#lx, %p, %#lx, %#lx, %p) = %p[%#lx]\n", | ||||||
|  |         lpFileName, | ||||||
|  |         dwDesiredAccess, | ||||||
|  |         dwShareMode, | ||||||
|  |         lpSecurityAttributes, | ||||||
|  |         dwCreationDisposition, | ||||||
|  |         dwFlagsAndAttributes, | ||||||
|  |         hTemplateFile, | ||||||
|  |         h, INVALID_HANDLE_VALUE != h ? 0 : LastError); | ||||||
|  |     SetLastError(LastError); | ||||||
|  |  | ||||||
|  |     return h; | ||||||
|  | } | ||||||
| @@ -4,14 +4,7 @@ | |||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| void getfileinfo_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | void getfileinfo_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -5,14 +5,7 @@ | |||||||
| #include <VersionHelpers.h> | #include <VersionHelpers.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| static void lock_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags) | static void lock_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -3,8 +3,7 @@ | |||||||
| #include <process.h> | #include <process.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| extern int WinFspDiskTests; | #include "winfsp-tests.h" | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout) | void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -3,8 +3,7 @@ | |||||||
| #include <process.h> | #include <process.h> | ||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
|  |  | ||||||
| extern int WinFspDiskTests; | #include "winfsp-tests.h" | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| void mount_invalid_test(void) | void mount_invalid_test(void) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| #include <winfsp/winfsp.h> | #include <winfsp/winfsp.h> | ||||||
| #include <tlib/testsuite.h> | #include <tlib/testsuite.h> | ||||||
|  |  | ||||||
|  | #include "winfsp-tests.h" | ||||||
|  |  | ||||||
| void path_prefix_test(void) | void path_prefix_test(void) | ||||||
| { | { | ||||||
|     PWSTR ipaths[] = |     PWSTR ipaths[] = | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ | |||||||
| #include <tlib/testsuite.h> | #include <tlib/testsuite.h> | ||||||
| #include <sddl.h> | #include <sddl.h> | ||||||
|  |  | ||||||
|  | #include "winfsp-tests.h" | ||||||
|  |  | ||||||
| void posix_map_sid_test(void) | void posix_map_sid_test(void) | ||||||
| { | { | ||||||
|     struct |     struct | ||||||
|   | |||||||
| @@ -5,14 +5,7 @@ | |||||||
| #include <VersionHelpers.h> | #include <VersionHelpers.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| static void rdwr_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags) | static void rdwr_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -3,14 +3,7 @@ | |||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| static void reparse_guid_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | static void reparse_guid_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -4,14 +4,7 @@ | |||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
| #include "memfs.h" | #include "memfs.h" | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | #include "winfsp-tests.h" | ||||||
| void *memfs_start(ULONG Flags); |  | ||||||
| void memfs_stop(void *data); |  | ||||||
| PWSTR memfs_volumename(void *data); |  | ||||||
|  |  | ||||||
| extern int NtfsTests; |  | ||||||
| extern int WinFspDiskTests; |  | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| void getsecurity_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | void getsecurity_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -3,8 +3,7 @@ | |||||||
| #include <process.h> | #include <process.h> | ||||||
| #include <strsafe.h> | #include <strsafe.h> | ||||||
|  |  | ||||||
| extern int WinFspDiskTests; | #include "winfsp-tests.h" | ||||||
| extern int WinFspNetTests; |  | ||||||
|  |  | ||||||
| static unsigned __stdcall timeout_pending_dotest_thread(void *FilePath) | static unsigned __stdcall timeout_pending_dotest_thread(void *FilePath) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| #include <tlib/testsuite.h> | #include <tlib/testsuite.h> | ||||||
|  |  | ||||||
|  | #include "winfsp-tests.h" | ||||||
|  |  | ||||||
| int NtfsTests = 0; | int NtfsTests = 0; | ||||||
| int WinFspDiskTests = 1; | int WinFspDiskTests = 1; | ||||||
| int WinFspNetTests = 1; | int WinFspNetTests = 1; | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								tst/winfsp-tests/winfsp-tests.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								tst/winfsp-tests/winfsp-tests.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | #include <windows.h> | ||||||
|  |  | ||||||
|  | void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | ||||||
|  | void *memfs_start(ULONG Flags); | ||||||
|  | void memfs_stop(void *data); | ||||||
|  | PWSTR memfs_volumename(void *data); | ||||||
|  |  | ||||||
|  | extern int NtfsTests; | ||||||
|  | extern int WinFspDiskTests; | ||||||
|  | extern int WinFspNetTests; | ||||||
|  |  | ||||||
|  | #define CreateFileW HookCreateFileW | ||||||
|  | HANDLE HookCreateFileW( | ||||||
|  |     LPCWSTR lpFileName, | ||||||
|  |     DWORD dwDesiredAccess, | ||||||
|  |     DWORD dwShareMode, | ||||||
|  |     LPSECURITY_ATTRIBUTES lpSecurityAttributes, | ||||||
|  |     DWORD dwCreationDisposition, | ||||||
|  |     DWORD dwFlagsAndAttributes, | ||||||
|  |     HANDLE hTemplateFile); | ||||||
		Reference in New Issue
	
	Block a user