ntdll-Junction_Points: Updates from Erich E. Hoover.

This commit is contained in:
Erich E. Hoover 2020-10-26 22:07:42 -05:00 committed by Zebediah Figura
parent d1a75649b7
commit 3dc5147b28
3 changed files with 53 additions and 15 deletions

View File

@ -1,4 +1,4 @@
From f0eee9d4ed2009f24799a149a70e0848dda9fe14 Mon Sep 17 00:00:00 2001
From 4de8fc9d34056aeb3307fa104bec6ca2c7748d2e Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 13 Mar 2019 16:02:05 -0600
Subject: kernel32: Implement CreateSymbolicLink[A|W] with ntdll reparse
@ -6,14 +6,38 @@ Subject: kernel32: Implement CreateSymbolicLink[A|W] with ntdll reparse
Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
---
dlls/kernel32/path.c | 12 +++-
dlls/kernel32/tests/path.c | 94 ++++++++++++++++++++++++++++++
dlls/kernelbase/file.c | 103 ++++++++++++++++++++++++++++++++-
dlls/msvcp120/tests/msvcp120.c | 75 +++++++++++-------------
dlls/msvcp140/tests/msvcp140.c | 63 +++++++++-----------
4 files changed, 256 insertions(+), 79 deletions(-)
5 files changed, 266 insertions(+), 81 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 8b4158b29d6..4384fab198d 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -348,8 +348,16 @@ WCHAR * CDECL wine_get_dos_file_name( LPCSTR str )
*/
BOOLEAN WINAPI CreateSymbolicLinkA(LPCSTR link, LPCSTR target, DWORD flags)
{
- FIXME("(%s %s %d): stub\n", debugstr_a(link), debugstr_a(target), flags);
- return TRUE;
+ WCHAR *linkW, *targetW;
+ BOOL ret;
+
+ if (!(linkW = FILE_name_AtoW( link, FALSE ))) return FALSE;
+ if (!(targetW = FILE_name_AtoW( target, TRUE ))) return FALSE;
+
+ ret = CreateSymbolicLinkW( linkW, targetW, flags );
+
+ HeapFree( GetProcessHeap(), 0, targetW );
+ return ret;
}
/*************************************************************************
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 0e45ad44ff3..0f8d94e2957 100644
index f49af6d5bfe..bc2cd84a65d 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -83,6 +83,9 @@ static NTSTATUS (WINAPI *pLdrGetDllPath)(LPCWSTR,ULONG,LPWSTR*,LPWSTR*);
@ -26,7 +50,7 @@ index 0e45ad44ff3..0f8d94e2957 100644
/* a structure to deal with wine todos somewhat cleanly */
typedef struct {
DWORD shortlen;
@@ -2147,6 +2150,7 @@ static void init_pointers(void)
@@ -2148,6 +2151,7 @@ static void init_pointers(void)
MAKEFUNC(SetDefaultDllDirectories);
MAKEFUNC(CheckNameLegalDOS8Dot3W);
MAKEFUNC(CheckNameLegalDOS8Dot3A);
@ -34,7 +58,7 @@ index 0e45ad44ff3..0f8d94e2957 100644
mod = GetModuleHandleA("ntdll.dll");
MAKEFUNC(LdrGetDllPath);
MAKEFUNC(RtlGetExePath);
@@ -2690,6 +2694,95 @@ static void test_LdrGetDllPath(void)
@@ -2691,6 +2695,95 @@ static void test_LdrGetDllPath(void)
SetEnvironmentVariableW( pathW, old_path );
}
@ -130,14 +154,14 @@ index 0e45ad44ff3..0f8d94e2957 100644
START_TEST(path)
{
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
@@ -2719,4 +2812,5 @@ START_TEST(path)
@@ -2720,4 +2813,5 @@ START_TEST(path)
test_RtlGetSearchPath();
test_RtlGetExePath();
test_LdrGetDllPath();
+ test_CreateSymbolicLink();
}
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index d9b34408692..2e67f6eaa3e 100644
index b265866ac54..caec31ce602 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -38,6 +38,7 @@
@ -148,7 +172,7 @@ index d9b34408692..2e67f6eaa3e 100644
#include "kernelbase.h"
#include "wine/exception.h"
@@ -926,8 +927,106 @@ done:
@@ -952,8 +953,106 @@ done:
*/
BOOLEAN WINAPI /* DECLSPEC_HOTPATCH */ CreateSymbolicLinkW( LPCWSTR link, LPCWSTR target, DWORD flags )
{

View File

@ -1,18 +1,18 @@
From 87cc49c8ae73e17bc953b66f25be76d5c0eff153 Mon Sep 17 00:00:00 2001
From 4a55bbf4a64741644288482073d29f9bfac8ffaf Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 29 May 2019 15:11:42 -0600
Subject: kernel32: Add reparse support to FindNextFile.
Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
---
dlls/kernelbase/file.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
dlls/kernelbase/file.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index 2e67f6eaa3e..9920b50191b 100644
index caec31ce602..a4536ec1c80 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -1485,6 +1485,27 @@ BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileW( HANDLE handle, WIN32_FIND_DATAW *da
@@ -1511,6 +1511,41 @@ BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileW( HANDLE handle, WIN32_FIND_DATAW *da
memcpy( data->cFileName, dir_info->FileName, dir_info->FileNameLength );
data->cFileName[dir_info->FileNameLength/sizeof(WCHAR)] = 0;
@ -24,12 +24,26 @@ index 2e67f6eaa3e..9920b50191b 100644
+ HANDLE hlink;
+ DWORD dwret;
+ BOOL bret;
+ INT path_len = info->path.Length + dir_info->FileNameLength +
+ sizeof(WCHAR);
+ WCHAR *path = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, path_len );
+
+ hlink = CreateFileW( data->cFileName, GENERIC_READ | GENERIC_WRITE, 0, 0,
+ if (!path) break;
+
+ lstrcpynW( path, info->path.Buffer, info->path.Length/sizeof(WCHAR) + 1 );
+ lstrcatW( path, data->cFileName );
+
+ hlink = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, 0, 0,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0 );
+ HeapFree( GetProcessHeap(), 0, path );
+ buffer_len = sizeof(*buffer) + 2*MAX_PATH*sizeof(WCHAR);
+ buffer = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, buffer_len );
+ if (!buffer)
+ {
+ CloseHandle( hlink );
+ break;
+ }
+ bret = DeviceIoControl( hlink, FSCTL_GET_REPARSE_POINT, NULL, 0, (LPVOID)buffer,
+ buffer_len, &dwret, 0 );
+ if (bret) data->dwReserved0 = buffer->ReparseTag;

View File

@ -2452,7 +2452,7 @@ fi
# | * [#44948] Multiple apps (Spine (Mod starter for Gothic), MS Office 365 installer) need CreateSymbolicLinkW implementation
# |
# | Modified files:
# | * configure.ac, dlls/kernel32/tests/path.c, dlls/kernelbase/file.c, dlls/msvcp120/tests/msvcp120.c,
# | * configure.ac, dlls/kernel32/path.c, dlls/kernel32/tests/path.c, dlls/kernelbase/file.c, dlls/msvcp120/tests/msvcp120.c,
# | dlls/msvcp140/tests/msvcp140.c, dlls/ntdll/tests/file.c, dlls/ntdll/unix/file.c, include/Makefile.in, include/ntifs.h,
# | include/winternl.h, programs/cmd/builtins.c, programs/cmd/directory.c, server/fd.c, server/protocol.def
# |