ntdll: Implement NtCreateDebugObject().
[wine.git] / dlls / ntdll / directory.c
blobcfb4595d457bdb6bdecec48afd8d25984250e323
1 /*
2 * NTDLL directory functions
4 * Copyright 1993 Erik Bos
5 * Copyright 2003 Eric Pouech
6 * Copyright 1996, 2004 Alexandre Julliard
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <assert.h>
24 #include <sys/types.h>
25 #include <fcntl.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include <stdio.h>
31 #include "ntstatus.h"
32 #define WIN32_NO_STATUS
33 #define NONAMELESSUNION
34 #include "windef.h"
35 #include "winnt.h"
36 #include "winternl.h"
37 #include "ddk/wdm.h"
38 #include "ntdll_misc.h"
39 #include "wine/server.h"
40 #include "wine/list.h"
41 #include "wine/debug.h"
42 #include "wine/exception.h"
44 #define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
46 static BOOL show_dot_files;
48 /***********************************************************************
49 * init_directories
51 void init_directories(void)
53 char tmp[80];
54 HANDLE root, hkey;
55 DWORD dummy;
56 OBJECT_ATTRIBUTES attr;
57 UNICODE_STRING nameW;
59 RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
60 attr.Length = sizeof(attr);
61 attr.RootDirectory = root;
62 attr.ObjectName = &nameW;
63 attr.Attributes = 0;
64 attr.SecurityDescriptor = NULL;
65 attr.SecurityQualityOfService = NULL;
66 RtlInitUnicodeString( &nameW, L"Software\\Wine" );
68 /* @@ Wine registry key: HKCU\Software\Wine */
69 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
71 RtlInitUnicodeString( &nameW, L"ShowDotFiles" );
72 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
74 WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
75 show_dot_files = IS_OPTION_TRUE( str[0] );
77 NtClose( hkey );
79 NtClose( root );
80 unix_funcs->set_show_dot_files( show_dot_files );
84 /******************************************************************
85 * RtlWow64EnableFsRedirection (NTDLL.@)
87 NTSTATUS WINAPI RtlWow64EnableFsRedirection( BOOLEAN enable )
89 #ifdef _WIN64
90 return STATUS_NOT_IMPLEMENTED;
91 #else
92 if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
93 NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = !enable;
94 return STATUS_SUCCESS;
95 #endif
99 /******************************************************************
100 * RtlWow64EnableFsRedirectionEx (NTDLL.@)
102 NTSTATUS WINAPI RtlWow64EnableFsRedirectionEx( ULONG disable, ULONG *old_value )
104 #ifdef _WIN64
105 return STATUS_NOT_IMPLEMENTED;
106 #else
107 if (!NtCurrentTeb64()) return STATUS_NOT_IMPLEMENTED;
109 __TRY
111 *old_value = NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR];
113 __EXCEPT_PAGE_FAULT
115 return STATUS_ACCESS_VIOLATION;
117 __ENDTRY
119 NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR] = disable;
120 return STATUS_SUCCESS;
121 #endif
125 /******************************************************************
126 * RtlDoesFileExists_U (NTDLL.@)
128 BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR file_name)
130 UNICODE_STRING nt_name;
131 FILE_BASIC_INFORMATION basic_info;
132 OBJECT_ATTRIBUTES attr;
133 BOOLEAN ret;
135 if (!RtlDosPathNameToNtPathName_U( file_name, &nt_name, NULL, NULL )) return FALSE;
137 attr.Length = sizeof(attr);
138 attr.RootDirectory = 0;
139 attr.ObjectName = &nt_name;
140 attr.Attributes = OBJ_CASE_INSENSITIVE;
141 attr.SecurityDescriptor = NULL;
142 attr.SecurityQualityOfService = NULL;
144 ret = NtQueryAttributesFile(&attr, &basic_info) == STATUS_SUCCESS;
146 RtlFreeUnicodeString( &nt_name );
147 return ret;