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-12-01 17:07:55 +01:00
|
|
|
/******************************************************************************
|
2020-06-12 14:20:16 +02:00
|
|
|
* NtQueryDirectoryFile [NTDLL.@]
|
|
|
|
* ZwQueryDirectoryFile [NTDLL.@]
|
2009-12-01 17:07:55 +01:00
|
|
|
*/
|
2020-06-12 14:20:16 +02:00
|
|
|
NTSTATUS WINAPI DECLSPEC_HOTPATCH NtQueryDirectoryFile( HANDLE handle, HANDLE event,
|
|
|
|
PIO_APC_ROUTINE apc_routine, PVOID apc_context,
|
|
|
|
PIO_STATUS_BLOCK io,
|
|
|
|
PVOID buffer, ULONG length,
|
|
|
|
FILE_INFORMATION_CLASS info_class,
|
|
|
|
BOOLEAN single_entry,
|
|
|
|
PUNICODE_STRING mask,
|
|
|
|
BOOLEAN restart_scan )
|
2009-12-01 17:07:55 +01:00
|
|
|
{
|
2020-06-12 14:20:16 +02:00
|
|
|
return unix_funcs->NtQueryDirectoryFile( handle, event, apc_routine, apc_context, io, buffer, length,
|
|
|
|
info_class, single_entry, mask, restart_scan );
|
2009-12-01 17:07:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-13 01:31:09 +02:00
|
|
|
/******************************************************************************
|
2004-04-23 04:46:18 +02:00
|
|
|
* wine_nt_to_unix_file_name (NTDLL.@) Not a Windows API
|
2004-04-13 01:31:09 +02:00
|
|
|
*
|
|
|
|
* Convert a file name from NT namespace to Unix namespace.
|
2004-04-22 00:26:44 +02:00
|
|
|
*
|
2008-04-08 23:22:43 +02:00
|
|
|
* If disposition is not FILE_OPEN or FILE_OVERWRITE, the last path
|
2004-04-27 04:15:52 +02:00
|
|
|
* element doesn't have to exist; in that case STATUS_NO_SUCH_FILE is
|
|
|
|
* returned, but the unix name is still filled in properly.
|
2004-04-13 01:31:09 +02:00
|
|
|
*/
|
2020-07-09 09:59:08 +02:00
|
|
|
NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, char *nameA, SIZE_T *size,
|
2020-06-26 14:26:55 +02:00
|
|
|
UINT disposition )
|
2004-04-13 01:31:09 +02:00
|
|
|
{
|
2020-07-09 09:59:08 +02:00
|
|
|
return unix_funcs->nt_to_unix_file_name( nameW, nameA, size, disposition );
|
2004-04-13 01:31:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-06 15:08:39 +02:00
|
|
|
/******************************************************************
|
|
|
|
* RtlWow64EnableFsRedirection (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable )
|
|
|
|
{
|
|
|
|
if (!is_wow64) return STATUS_NOT_IMPLEMENTED;
|
|
|
|
ntdll_get_thread_data()->wow64_redir = enable;
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* 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
|
|
|
{
|
|
|
|
if (!is_wow64) return STATUS_NOT_IMPLEMENTED;
|
2012-08-21 21:58:17 +02:00
|
|
|
|
2016-08-07 00:00:21 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
*old_value = !ntdll_get_thread_data()->wow64_redir;
|
|
|
|
}
|
|
|
|
__EXCEPT_PAGE_FAULT
|
|
|
|
{
|
|
|
|
return STATUS_ACCESS_VIOLATION;
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2009-10-28 10:54:22 +01:00
|
|
|
ntdll_get_thread_data()->wow64_redir = !disable;
|
2009-07-06 15:08:39 +02:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|