2004-03-16 02:32:02 +01:00
|
|
|
/*
|
|
|
|
* NTDLL directory functions
|
|
|
|
*
|
|
|
|
* Copyright 1993 Erik Bos
|
|
|
|
* Copyright 2003 Eric Pouech
|
|
|
|
* Copyright 1996, 2004 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-16 02:32:02 +01:00
|
|
|
*/
|
|
|
|
|
2008-10-28 13:55:24 +01:00
|
|
|
#include <assert.h>
|
2004-03-16 02:32:02 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2004-04-29 22:04:48 +02:00
|
|
|
#include <stdio.h>
|
2004-03-16 02:32:02 +01:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2015-03-14 03:38:17 +01:00
|
|
|
#define NONAMELESSUNION
|
2004-03-16 02:32:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winnt.h"
|
|
|
|
#include "winternl.h"
|
2011-06-16 12:27:01 +02:00
|
|
|
#include "ddk/wdm.h"
|
2004-03-16 02:32:02 +01:00
|
|
|
#include "ntdll_misc.h"
|
|
|
|
#include "wine/server.h"
|
2009-12-09 23:34:45 +01:00
|
|
|
#include "wine/list.h"
|
2004-03-16 02:32:02 +01:00
|
|
|
#include "wine/debug.h"
|
2016-08-07 00:00:21 +02:00
|
|
|
#include "wine/exception.h"
|
2004-03-16 02:32:02 +01:00
|
|
|
|
|
|
|
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
|
|
|
|
|
2013-08-29 16:48:23 +02:00
|
|
|
static BOOL show_dot_files;
|
2009-10-22 20:06:06 +02:00
|
|
|
|
2020-06-12 14:20:16 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* init_directories
|
2009-12-02 17:35:43 +01:00
|
|
|
*/
|
2020-06-12 14:20:16 +02:00
|
|
|
void init_directories(void)
|
2009-12-02 17:35:43 +01:00
|
|
|
{
|
2020-06-12 14:20:16 +02:00
|
|
|
static const WCHAR WineW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e',0};
|
|
|
|
static const WCHAR ShowDotFilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0};
|
|
|
|
char tmp[80];
|
|
|
|
HANDLE root, hkey;
|
|
|
|
DWORD dummy;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
UNICODE_STRING nameW;
|
2009-12-02 17:35:43 +01:00
|
|
|
|
2020-06-12 14:20:16 +02:00
|
|
|
RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = root;
|
|
|
|
attr.ObjectName = &nameW;
|
|
|
|
attr.Attributes = 0;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
RtlInitUnicodeString( &nameW, WineW );
|
2009-12-09 23:34:45 +01:00
|
|
|
|
2020-06-12 14:20:16 +02:00
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine */
|
|
|
|
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
|
2009-12-09 23:34:45 +01:00
|
|
|
{
|
2020-06-12 14:20:16 +02:00
|
|
|
RtlInitUnicodeString( &nameW, ShowDotFilesW );
|
|
|
|
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
2009-12-02 17:35:43 +01:00
|
|
|
{
|
2020-06-12 14:20:16 +02:00
|
|
|
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
|
|
|
show_dot_files = IS_OPTION_TRUE( str[0] );
|
2009-12-02 17:35:43 +01:00
|
|
|
}
|
2020-06-12 14:20:16 +02:00
|
|
|
NtClose( hkey );
|
2009-12-02 17:35:43 +01:00
|
|
|
}
|
2020-06-12 14:20:16 +02:00
|
|
|
NtClose( root );
|
|
|
|
unix_funcs->set_show_dot_files( show_dot_files );
|
2009-12-02 17:35:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-06 15:08:39 +02:00
|
|
|
/******************************************************************
|
|
|
|
* RtlWow64EnableFsRedirection (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable )
|
|
|
|
{
|
2020-07-24 13:29:31 +02:00
|
|
|
#ifdef _WIN64
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
#else
|
|
|
|
if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
|
|
|
|
NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = !enable;
|
2009-07-06 15:08:39 +02:00
|
|
|
return STATUS_SUCCESS;
|
2020-07-24 13:29:31 +02:00
|
|
|
#endif
|
2009-07-06 15:08:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* RtlWow64EnableFsRedirectionEx (NTDLL.@)
|
|
|
|
*/
|
2009-10-28 10:54:22 +01:00
|
|
|
NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
|
2009-07-06 15:08:39 +02:00
|
|
|
{
|
2020-07-24 13:29:31 +02:00
|
|
|
#ifdef _WIN64
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
#else
|
|
|
|
if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
|
2012-08-21 21:58:17 +02:00
|
|
|
|
2016-08-07 00:00:21 +02:00
|
|
|
__TRY
|
|
|
|
{
|
2020-07-24 13:29:31 +02:00
|
|
|
*old_value = NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR];
|
2016-08-07 00:00:21 +02:00
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2020-07-24 13:29:31 +02:00
|
|
|
NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = disable;
|
2009-07-06 15:08:39 +02:00
|
|
|
return STATUS_SUCCESS;
|
2020-07-24 13:29:31 +02:00
|
|
|
#endif
|
2009-07-06 15:08:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-13 01:31:09 +02:00
|
|
|
/******************************************************************
|
|
|
|
* RtlDoesFileExists_U (NTDLL.@)
|
|
|
|
*/
|
|
|
|
BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR file_name)
|
|
|
|
{
|
|
|
|
UNICODE_STRING nt_name;
|
2007-05-03 22:33:58 +02:00
|
|
|
FILE_BASIC_INFORMATION basic_info;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
2004-04-13 01:31:09 +02:00
|
|
|
BOOLEAN ret;
|
|
|
|
|
|
|
|
if (!RtlDosPathNameToNtPathName_U( file_name, &nt_name, NULL, NULL )) return FALSE;
|
2007-05-03 22:33:58 +02:00
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.ObjectName = &nt_name;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE;
|
|
|
|
attr.SecurityDescriptor = NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
|
|
|
ret = NtQueryAttributesFile(&attr, &basic_info) == STATUS_SUCCESS;
|
|
|
|
|
2004-04-13 01:31:09 +02:00
|
|
|
RtlFreeUnicodeString( &nt_name );
|
|
|
|
return ret;
|
|
|
|
}
|