diff --git a/build/VStudio/testing/winfsp-tests.vcxproj b/build/VStudio/testing/winfsp-tests.vcxproj
index e7e2912a..c9408059 100644
--- a/build/VStudio/testing/winfsp-tests.vcxproj
+++ b/build/VStudio/testing/winfsp-tests.vcxproj
@@ -186,6 +186,7 @@
+
@@ -201,6 +202,7 @@
+
diff --git a/build/VStudio/testing/winfsp-tests.vcxproj.filters b/build/VStudio/testing/winfsp-tests.vcxproj.filters
index cbed71c6..dc201cd9 100644
--- a/build/VStudio/testing/winfsp-tests.vcxproj.filters
+++ b/build/VStudio/testing/winfsp-tests.vcxproj.filters
@@ -64,6 +64,9 @@
Source
+
+ Source
+
@@ -72,5 +75,8 @@
Source
+
+ Source
+
\ No newline at end of file
diff --git a/tst/winfsp-tests/create-test.c b/tst/winfsp-tests/create-test.c
index e6d8735e..6e352529 100644
--- a/tst/winfsp-tests/create-test.c
+++ b/tst/winfsp-tests/create-test.c
@@ -4,13 +4,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
void create_dotest(ULONG Flags, PWSTR Prefix)
{
diff --git a/tst/winfsp-tests/dirctl-test.c b/tst/winfsp-tests/dirctl-test.c
index d6ae38ed..0e9a529a 100644
--- a/tst/winfsp-tests/dirctl-test.c
+++ b/tst/winfsp-tests/dirctl-test.c
@@ -5,14 +5,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
static void querydir_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout, ULONG SleepTimeout)
{
diff --git a/tst/winfsp-tests/eventlog-test.c b/tst/winfsp-tests/eventlog-test.c
index 9a4610c0..8b429ec8 100644
--- a/tst/winfsp-tests/eventlog-test.c
+++ b/tst/winfsp-tests/eventlog-test.c
@@ -1,6 +1,8 @@
#include
#include
+#include "winfsp-tests.h"
+
void eventlog_test(void)
{
/* this is not a real test! */
diff --git a/tst/winfsp-tests/flush-test.c b/tst/winfsp-tests/flush-test.c
index 1fd032e3..3a9a6184 100644
--- a/tst/winfsp-tests/flush-test.c
+++ b/tst/winfsp-tests/flush-test.c
@@ -5,14 +5,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
static void flush_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags,
BOOLEAN FlushVolume)
diff --git a/tst/winfsp-tests/fuse-opt-test.c b/tst/winfsp-tests/fuse-opt-test.c
index 6ce8554b..19120141 100644
--- a/tst/winfsp-tests/fuse-opt-test.c
+++ b/tst/winfsp-tests/fuse-opt-test.c
@@ -3,6 +3,8 @@
#include
#include
+#include "winfsp-tests.h"
+
struct data
{
int fortytwo;
diff --git a/tst/winfsp-tests/hook.c b/tst/winfsp-tests/hook.c
new file mode 100644
index 00000000..8e1c8fd2
--- /dev/null
+++ b/tst/winfsp-tests/hook.c
@@ -0,0 +1,34 @@
+#include
+
+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;
+}
diff --git a/tst/winfsp-tests/info-test.c b/tst/winfsp-tests/info-test.c
index 90c69f16..acbba630 100644
--- a/tst/winfsp-tests/info-test.c
+++ b/tst/winfsp-tests/info-test.c
@@ -4,14 +4,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
void getfileinfo_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)
{
diff --git a/tst/winfsp-tests/lock-test.c b/tst/winfsp-tests/lock-test.c
index ce8a5b1b..d8c5030a 100644
--- a/tst/winfsp-tests/lock-test.c
+++ b/tst/winfsp-tests/lock-test.c
@@ -5,14 +5,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
static void lock_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags)
{
diff --git a/tst/winfsp-tests/memfs-test.c b/tst/winfsp-tests/memfs-test.c
index 95ba100c..208d8aed 100644
--- a/tst/winfsp-tests/memfs-test.c
+++ b/tst/winfsp-tests/memfs-test.c
@@ -3,8 +3,7 @@
#include
#include "memfs.h"
-extern int WinFspDiskTests;
-extern int WinFspNetTests;
+#include "winfsp-tests.h"
void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout)
{
diff --git a/tst/winfsp-tests/mount-test.c b/tst/winfsp-tests/mount-test.c
index 2457e05e..c5303078 100644
--- a/tst/winfsp-tests/mount-test.c
+++ b/tst/winfsp-tests/mount-test.c
@@ -3,8 +3,7 @@
#include
#include
-extern int WinFspDiskTests;
-extern int WinFspNetTests;
+#include "winfsp-tests.h"
void mount_invalid_test(void)
{
diff --git a/tst/winfsp-tests/path-test.c b/tst/winfsp-tests/path-test.c
index a0d648aa..309b8e02 100644
--- a/tst/winfsp-tests/path-test.c
+++ b/tst/winfsp-tests/path-test.c
@@ -1,6 +1,8 @@
#include
#include
+#include "winfsp-tests.h"
+
void path_prefix_test(void)
{
PWSTR ipaths[] =
diff --git a/tst/winfsp-tests/posix-test.c b/tst/winfsp-tests/posix-test.c
index 8ac37779..d717e7a2 100644
--- a/tst/winfsp-tests/posix-test.c
+++ b/tst/winfsp-tests/posix-test.c
@@ -2,6 +2,8 @@
#include
#include
+#include "winfsp-tests.h"
+
void posix_map_sid_test(void)
{
struct
diff --git a/tst/winfsp-tests/rdwr-test.c b/tst/winfsp-tests/rdwr-test.c
index 87cf9bd4..8bd663dd 100644
--- a/tst/winfsp-tests/rdwr-test.c
+++ b/tst/winfsp-tests/rdwr-test.c
@@ -5,14 +5,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
static void rdwr_dotest(ULONG Flags, PWSTR VolPrefix, PWSTR Prefix, ULONG FileInfoTimeout, DWORD CreateFlags)
{
diff --git a/tst/winfsp-tests/reparse-test.c b/tst/winfsp-tests/reparse-test.c
index 3dac2f29..f658849e 100644
--- a/tst/winfsp-tests/reparse-test.c
+++ b/tst/winfsp-tests/reparse-test.c
@@ -3,14 +3,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
static void reparse_guid_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)
{
diff --git a/tst/winfsp-tests/security-test.c b/tst/winfsp-tests/security-test.c
index 9e7a6d07..acd7006b 100644
--- a/tst/winfsp-tests/security-test.c
+++ b/tst/winfsp-tests/security-test.c
@@ -4,14 +4,7 @@
#include
#include "memfs.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;
+#include "winfsp-tests.h"
void getsecurity_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)
{
diff --git a/tst/winfsp-tests/timeout-test.c b/tst/winfsp-tests/timeout-test.c
index cb4c12ba..fff2d5e6 100644
--- a/tst/winfsp-tests/timeout-test.c
+++ b/tst/winfsp-tests/timeout-test.c
@@ -3,8 +3,7 @@
#include
#include
-extern int WinFspDiskTests;
-extern int WinFspNetTests;
+#include "winfsp-tests.h"
static unsigned __stdcall timeout_pending_dotest_thread(void *FilePath)
{
diff --git a/tst/winfsp-tests/winfsp-tests.c b/tst/winfsp-tests/winfsp-tests.c
index 193b52a8..9fcf3f7d 100644
--- a/tst/winfsp-tests/winfsp-tests.c
+++ b/tst/winfsp-tests/winfsp-tests.c
@@ -1,5 +1,7 @@
#include
+#include "winfsp-tests.h"
+
int NtfsTests = 0;
int WinFspDiskTests = 1;
int WinFspNetTests = 1;
diff --git a/tst/winfsp-tests/winfsp-tests.h b/tst/winfsp-tests/winfsp-tests.h
new file mode 100644
index 00000000..712db3b2
--- /dev/null
+++ b/tst/winfsp-tests/winfsp-tests.h
@@ -0,0 +1,20 @@
+#include
+
+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);