ReactOS 0.4.16-dev-1520-gb558596
file.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "winerror.h"
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "winioctl.h"
#include "wincon.h"
#include "fileapi.h"
#include "shlwapi.h"
#include "ddk/ntddk.h"
#include "ddk/ntddser.h"
#include "ioringapi.h"
#include "kernelbase.h"
#include "wine/exception.h"
#include "wine/debug.h"
Include dependency graph for file.c:

Go to the source code of this file.

Classes

struct  FIND_FIRST_INFO
 

Macros

#define WIN32_NO_STATUS
 
#define FIND_FIRST_MAGIC   0xc0ffee11
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (file)
 
static void WINAPI read_write_apc (void *apc_user, PIO_STATUS_BLOCK io, ULONG reserved)
 
static const WCHARget_machine_wow64_dir (WORD machine)
 
static BOOL contains_path (const WCHAR *name)
 
static BOOL add_boot_rename_entry (LPCWSTR source, LPCWSTR dest, DWORD flags)
 
static WCHARappend_ext (const WCHAR *name, const WCHAR *ext)
 
static NTSTATUS find_actctx_dllpath (const WCHAR *name, WCHAR **path)
 
static DWORD copy_filename (const WCHAR *name, WCHAR *buffer, DWORD len)
 
static DWORD copy_filename_WtoA (LPCWSTR nameW, LPSTR buffer, DWORD len)
 
WCHARfile_name_AtoW (LPCSTR name, BOOL alloc)
 
DWORD file_name_WtoA (LPCWSTR src, INT srclen, LPSTR dest, INT destlen)
 
static BOOL is_same_file (HANDLE h1, HANDLE h2)
 
BOOL WINAPI DECLSPEC_HOTPATCH AreFileApisANSI (void)
 
static BOOL copy_file (const WCHAR *source, const WCHAR *dest, COPYFILE2_EXTENDED_PARAMETERS *params)
 
HRESULT WINAPI CopyFile2 (const WCHAR *source, const WCHAR *dest, COPYFILE2_EXTENDED_PARAMETERS *params)
 
BOOL WINAPI CopyFileExW (const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUTINE progress, void *param, BOOL *cancel_ptr, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH CopyFileW (const WCHAR *source, const WCHAR *dest, BOOL fail_if_exists)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryA (LPCSTR path, LPSECURITY_ATTRIBUTES sa)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryW (LPCWSTR path, LPSECURITY_ATTRIBUTES sa)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryExW (LPCWSTR template, LPCWSTR path, LPSECURITY_ATTRIBUTES sa)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateFile2 (LPCWSTR name, DWORD access, DWORD sharing, DWORD creation, CREATEFILE2_EXTENDED_PARAMETERS *params)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileA (LPCSTR name, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, DWORD attributes, HANDLE template)
 
static UINT get_nt_file_options (DWORD attributes)
 
HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileW (LPCWSTR filename, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, DWORD attributes, HANDLE template)
 
BOOL WINAPI DECLSPEC_HOTPATCH CreateHardLinkA (const char *dest, const char *source, SECURITY_ATTRIBUTES *attr)
 
BOOL WINAPI CreateHardLinkW (LPCWSTR dest, LPCWSTR source, SECURITY_ATTRIBUTES *sec_attr)
 
BOOLEAN WINAPI CreateSymbolicLinkW (LPCWSTR link, LPCWSTR target, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH DeleteFileA (LPCSTR path)
 
BOOL WINAPI DECLSPEC_HOTPATCH DeleteFileW (LPCWSTR path)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindCloseChangeNotification (HANDLE handle)
 
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstChangeNotificationA (LPCSTR path, BOOL subtree, DWORD filter)
 
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstChangeNotificationW (LPCWSTR path, BOOL subtree, DWORD filter)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindNextChangeNotification (HANDLE handle)
 
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExA (const char *filename, FINDEX_INFO_LEVELS level, void *data, FINDEX_SEARCH_OPS search_op, void *filter, DWORD flags)
 
static WCHARfixup_mask (const WCHAR *mask)
 
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW (LPCWSTR filename, FINDEX_INFO_LEVELS level, LPVOID data, FINDEX_SEARCH_OPS search_op, LPVOID filter, DWORD flags)
 
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileA (const char *filename, WIN32_FIND_DATAA *data)
 
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileW (const WCHAR *filename, WIN32_FIND_DATAW *data)
 
HANDLE WINAPI FindFirstFileNameW (const WCHAR *file_name, DWORD flags, DWORD *len, WCHAR *link_name)
 
HANDLE WINAPI FindFirstStreamW (const WCHAR *filename, STREAM_INFO_LEVELS level, void *data, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileA (HANDLE handle, WIN32_FIND_DATAA *data)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileW (HANDLE handle, WIN32_FIND_DATAW *data)
 
BOOL WINAPI FindNextStreamW (HANDLE handle, void *data)
 
BOOL WINAPI DECLSPEC_HOTPATCH FindClose (HANDLE handle)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetCompressedFileSizeA (LPCSTR name, LPDWORD size_high)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetCompressedFileSizeW (LPCWSTR name, LPDWORD size_high)
 
UINT WINAPI DECLSPEC_HOTPATCH GetCurrentDirectoryA (UINT buflen, LPSTR buf)
 
UINT WINAPI DECLSPEC_HOTPATCH GetCurrentDirectoryW (UINT buflen, LPWSTR buf)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFileAttributesA (LPCSTR name)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFileAttributesW (LPCWSTR name)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetFileAttributesExA (LPCSTR name, GET_FILEEX_INFO_LEVELS level, void *ptr)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetFileAttributesExW (LPCWSTR name, GET_FILEEX_INFO_LEVELS level, void *ptr)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFinalPathNameByHandleA (HANDLE file, LPSTR path, DWORD count, DWORD flags)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFinalPathNameByHandleW (HANDLE file, LPWSTR path, DWORD count, DWORD flags)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFullPathNameA (LPCSTR name, DWORD len, LPSTR buffer, LPSTR *lastpart)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFullPathNameW (LPCWSTR name, DWORD len, LPWSTR buffer, LPWSTR *lastpart)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameA (LPCSTR shortpath, LPSTR longpath, DWORD longlen)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW (LPCWSTR shortpath, LPWSTR longpath, DWORD longlen)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetShortPathNameW (LPCWSTR longpath, LPWSTR shortpath, DWORD shortlen)
 
UINT WINAPI DECLSPEC_HOTPATCH GetSystemDirectoryA (LPSTR path, UINT count)
 
UINT WINAPI DECLSPEC_HOTPATCH GetSystemDirectoryW (LPWSTR path, UINT count)
 
UINT WINAPI DECLSPEC_HOTPATCH GetSystemWindowsDirectoryA (LPSTR path, UINT count)
 
UINT WINAPI DECLSPEC_HOTPATCH GetSystemWindowsDirectoryW (LPWSTR path, UINT count)
 
UINT WINAPI GetSystemWow64DirectoryA (LPSTR path, UINT count)
 
UINT WINAPI GetSystemWow64DirectoryW (LPWSTR path, UINT count)
 
UINT WINAPI DECLSPEC_HOTPATCH GetSystemWow64Directory2A (LPSTR path, UINT count, WORD machine)
 
UINT WINAPI DECLSPEC_HOTPATCH GetSystemWow64Directory2W (LPWSTR path, UINT count, WORD machine)
 
UINT WINAPI DECLSPEC_HOTPATCH GetTempFileNameA (LPCSTR path, LPCSTR prefix, UINT unique, LPSTR buffer)
 
UINT WINAPI DECLSPEC_HOTPATCH GetTempFileNameW (LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR buffer)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPathA (DWORD count, LPSTR path)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPathW (DWORD count, LPWSTR path)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPath2A (DWORD count, LPSTR path)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPath2W (DWORD count, LPWSTR path)
 
UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryA (LPSTR path, UINT count)
 
UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryW (LPWSTR path, UINT count)
 
BOOL WINAPI MoveFileExW (const WCHAR *source, const WCHAR *dest, DWORD flag)
 
BOOL WINAPI DECLSPEC_HOTPATCH MoveFileWithProgressW (const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUTINE progress, void *param, DWORD flag)
 
BOOL WINAPI DECLSPEC_HOTPATCH NeedCurrentDirectoryForExePathA (LPCSTR name)
 
BOOL WINAPI DECLSPEC_HOTPATCH NeedCurrentDirectoryForExePathW (LPCWSTR name)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReplaceFileW (const WCHAR *replaced, const WCHAR *replacement, const WCHAR *backup, DWORD flags, void *exclude, void *reserved)
 
DWORD WINAPI DECLSPEC_HOTPATCH SearchPathA (LPCSTR path, LPCSTR name, LPCSTR ext, DWORD buflen, LPSTR buffer, LPSTR *lastpart)
 
DWORD WINAPI DECLSPEC_HOTPATCH SearchPathW (LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen, LPWSTR buffer, LPWSTR *lastpart)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCurrentDirectoryA (LPCSTR dir)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCurrentDirectoryW (LPCWSTR dir)
 
void WINAPI DECLSPEC_HOTPATCH SetFileApisToANSI (void)
 
void WINAPI DECLSPEC_HOTPATCH SetFileApisToOEM (void)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetFileAttributesA (LPCSTR name, DWORD attributes)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetFileAttributesW (LPCWSTR name, DWORD attributes)
 
BOOL WINAPI DECLSPEC_HOTPATCH Wow64DisableWow64FsRedirection (PVOID *old_value)
 
DWORD WINAPI kernelbase_Wow64EnableWow64FsRedirection (BOOLEAN enable)
 
BOOL WINAPI DECLSPEC_HOTPATCH Wow64RevertWow64FsRedirection (PVOID old_value)
 
BOOL WINAPI DECLSPEC_HOTPATCH CancelIo (HANDLE handle)
 
BOOL WINAPI DECLSPEC_HOTPATCH CancelIoEx (HANDLE handle, LPOVERLAPPED overlapped)
 
BOOL WINAPI DECLSPEC_HOTPATCH CancelSynchronousIo (HANDLE thread)
 
BOOL WINAPI DECLSPEC_HOTPATCH FlushFileBuffers (HANDLE file)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetFileInformationByHandle (HANDLE file, BY_HANDLE_FILE_INFORMATION *info)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetFileInformationByHandleEx (HANDLE handle, FILE_INFO_BY_HANDLE_CLASS class, LPVOID info, DWORD size)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFileSize (HANDLE file, LPDWORD size_high)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetFileSizeEx (HANDLE file, PLARGE_INTEGER size)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetFileTime (HANDLE file, FILETIME *creation, FILETIME *access, FILETIME *write)
 
DWORD WINAPI DECLSPEC_HOTPATCH GetFileType (HANDLE file)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResult (HANDLE file, LPOVERLAPPED overlapped, LPDWORD result, BOOL wait)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResultEx (HANDLE file, OVERLAPPED *overlapped, DWORD *result, DWORD timeout, BOOL alertable)
 
BOOL WINAPI DECLSPEC_HOTPATCH LockFile (HANDLE file, DWORD offset_low, DWORD offset_high, DWORD count_low, DWORD count_high)
 
BOOL WINAPI DECLSPEC_HOTPATCH LockFileEx (HANDLE file, DWORD flags, DWORD reserved, DWORD count_low, DWORD count_high, LPOVERLAPPED overlapped)
 
HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileById (HANDLE handle, LPFILE_ID_DESCRIPTOR id, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES sec_attr, DWORD flags)
 
HANDLE WINAPI DECLSPEC_HOTPATCH ReOpenFile (HANDLE handle, DWORD access, DWORD sharing, DWORD attributes)
 
static void WINAPI invoke_completion (void *context, IO_STATUS_BLOCK *io, ULONG res)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadDirectoryChangesW (HANDLE handle, LPVOID buffer, DWORD len, BOOL subtree, DWORD filter, LPDWORD returned, LPOVERLAPPED overlapped, LPOVERLAPPED_COMPLETION_ROUTINE completion)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadFile (HANDLE file, LPVOID buffer, DWORD count, LPDWORD result, LPOVERLAPPED overlapped)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadFileEx (HANDLE file, LPVOID buffer, DWORD count, LPOVERLAPPED overlapped, LPOVERLAPPED_COMPLETION_ROUTINE completion)
 
BOOL WINAPI DECLSPEC_HOTPATCH ReadFileScatter (HANDLE file, FILE_SEGMENT_ELEMENT *segments, DWORD count, LPDWORD reserved, LPOVERLAPPED overlapped)
 
BOOL WINAPI DECLSPEC_HOTPATCH RemoveDirectoryA (LPCSTR path)
 
BOOL WINAPI DECLSPEC_HOTPATCH RemoveDirectoryW (LPCWSTR path)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetEndOfFile (HANDLE file)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetFileInformationByHandle (HANDLE file, FILE_INFO_BY_HANDLE_CLASS class, void *info, DWORD size)
 
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer (HANDLE file, LONG distance, LONG *highword, DWORD method)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetFilePointerEx (HANDLE file, LARGE_INTEGER distance, LARGE_INTEGER *newpos, DWORD method)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetFileTime (HANDLE file, const FILETIME *ctime, const FILETIME *atime, const FILETIME *mtime)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetFileValidData (HANDLE file, LONGLONG length)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnlockFile (HANDLE file, DWORD offset_low, DWORD offset_high, DWORD count_low, DWORD count_high)
 
BOOL WINAPI DECLSPEC_HOTPATCH UnlockFileEx (HANDLE file, DWORD reserved, DWORD count_low, DWORD count_high, LPOVERLAPPED overlapped)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteFile (HANDLE file, LPCVOID buffer, DWORD count, LPDWORD result, LPOVERLAPPED overlapped)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteFileEx (HANDLE file, LPCVOID buffer, DWORD count, LPOVERLAPPED overlapped, LPOVERLAPPED_COMPLETION_ROUTINE completion)
 
BOOL WINAPI DECLSPEC_HOTPATCH WriteFileGather (HANDLE file, FILE_SEGMENT_ELEMENT *segments, DWORD count, LPDWORD reserved, LPOVERLAPPED overlapped)
 
INT WINAPI DECLSPEC_HOTPATCH CompareFileTime (const FILETIME *x, const FILETIME *y)
 
BOOL WINAPI DECLSPEC_HOTPATCH FileTimeToLocalFileTime (const FILETIME *utc, FILETIME *local)
 
BOOL WINAPI DECLSPEC_HOTPATCH FileTimeToSystemTime (const FILETIME *ft, SYSTEMTIME *systime)
 
void WINAPI DECLSPEC_HOTPATCH GetLocalTime (SYSTEMTIME *systime)
 
void WINAPI DECLSPEC_HOTPATCH GetSystemTime (SYSTEMTIME *systime)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetSystemTimeAdjustment (DWORD *adjust, DWORD *increment, BOOL *disabled)
 
void WINAPI DECLSPEC_HOTPATCH GetSystemTimeAsFileTime (FILETIME *time)
 
void WINAPI DECLSPEC_HOTPATCH GetSystemTimePreciseAsFileTime (FILETIME *time)
 
BOOL WINAPI DECLSPEC_HOTPATCH LocalFileTimeToFileTime (const FILETIME *local, FILETIME *utc)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetLocalTime (const SYSTEMTIME *systime)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetSystemTime (const SYSTEMTIME *systime)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetSystemTimeAdjustment (DWORD adjust, BOOL disabled)
 
BOOL WINAPI DECLSPEC_HOTPATCH SystemTimeToFileTime (const SYSTEMTIME *systime, FILETIME *ft)
 
static void dump_dcb (const DCB *dcb)
 
BOOL WINAPI DECLSPEC_HOTPATCH ClearCommBreak (HANDLE handle)
 
BOOL WINAPI DECLSPEC_HOTPATCH ClearCommError (HANDLE handle, DWORD *errors, COMSTAT *stat)
 
BOOL WINAPI DECLSPEC_HOTPATCH DeviceIoControl (HANDLE handle, DWORD code, void *in_buff, DWORD in_count, void *out_buff, DWORD out_count, DWORD *returned, OVERLAPPED *overlapped)
 
BOOL WINAPI DECLSPEC_HOTPATCH EscapeCommFunction (HANDLE handle, DWORD func)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCommConfig (HANDLE handle, COMMCONFIG *config, DWORD *size)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCommMask (HANDLE handle, DWORD *mask)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCommModemStatus (HANDLE handle, DWORD *status)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCommProperties (HANDLE handle, COMMPROP *prop)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCommState (HANDLE handle, DCB *dcb)
 
BOOL WINAPI DECLSPEC_HOTPATCH GetCommTimeouts (HANDLE handle, COMMTIMEOUTS *timeouts)
 
BOOL WINAPI DECLSPEC_HOTPATCH PurgeComm (HANDLE handle, DWORD flags)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCommBreak (HANDLE handle)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCommConfig (HANDLE handle, COMMCONFIG *config, DWORD size)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCommMask (HANDLE handle, DWORD mask)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCommState (HANDLE handle, DCB *dcb)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetCommTimeouts (HANDLE handle, COMMTIMEOUTS *timeouts)
 
BOOL WINAPI DECLSPEC_HOTPATCH SetupComm (HANDLE handle, DWORD in_size, DWORD out_size)
 
BOOL WINAPI DECLSPEC_HOTPATCH TransmitCommChar (HANDLE handle, CHAR ch)
 
BOOL WINAPI DECLSPEC_HOTPATCH WaitCommEvent (HANDLE handle, DWORD *events, OVERLAPPED *overlapped)
 
HRESULT WINAPI QueryIoRingCapabilities (IORING_CAPABILITIES *caps)
 

Variables

static const UINT max_entry_size = offsetof( FILE_BOTH_DIRECTORY_INFORMATION, FileName[256] )
 
const WCHAR windows_dir [] = L"C:\\windows"
 
const WCHAR system_dir [] = L"C:\\windows\\system32"
 
static BOOL oem_file_apis
 
static IO_STATUS_BLOCK dummy_iosb
 

Macro Definition Documentation

◆ FIND_FIRST_MAGIC

#define FIND_FIRST_MAGIC   0xc0ffee11

Definition at line 63 of file file.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 28 of file file.c.

Function Documentation

◆ add_boot_rename_entry()

static BOOL add_boot_rename_entry ( LPCWSTR  source,
LPCWSTR  dest,
DWORD  flags 
)
static

Definition at line 142 of file file.c.

143{
144 static const int info_size = FIELD_OFFSET( KEY_VALUE_PARTIAL_INFORMATION, Data );
145
147 UNICODE_STRING session_manager = RTL_CONSTANT_STRING( L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager" );
148 UNICODE_STRING pending_file_rename_operations = RTL_CONSTANT_STRING( L"PendingFileRenameOperations" );
149 UNICODE_STRING source_name, dest_name;
151 BOOL rc = FALSE;
152 HANDLE key = 0;
153 DWORD len1, len2;
154 DWORD size = 0;
155 BYTE *buffer = NULL;
156 WCHAR *p;
157
158 if (!RtlDosPathNameToNtPathName_U( source, &source_name, NULL, NULL ))
159 {
161 return FALSE;
162 }
163 dest_name.Buffer = NULL;
164 if (dest && !RtlDosPathNameToNtPathName_U( dest, &dest_name, NULL, NULL ))
165 {
166 RtlFreeUnicodeString( &source_name );
168 return FALSE;
169 }
170
171 attr.Length = sizeof(attr);
172 attr.RootDirectory = 0;
173 attr.ObjectName = &session_manager;
174 attr.Attributes = 0;
175 attr.SecurityDescriptor = NULL;
176 attr.SecurityQualityOfService = NULL;
177
179 {
180 RtlFreeUnicodeString( &source_name );
181 RtlFreeUnicodeString( &dest_name );
182 return FALSE;
183 }
184
185 len1 = source_name.Length + sizeof(WCHAR);
186 if (dest)
187 {
188 len2 = dest_name.Length + sizeof(WCHAR);
190 len2 += sizeof(WCHAR); /* Plus 1 because of the leading '!' */
191 }
192 else len2 = sizeof(WCHAR); /* minimum is the 0 characters for the empty second string */
193
194 /* First we check if the key exists and if so how many bytes it already contains. */
195 if (NtQueryValueKey( key, &pending_file_rename_operations, KeyValuePartialInformation,
197 {
198 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size + len1 + len2 + sizeof(WCHAR) ))) goto done;
199 if (NtQueryValueKey( key, &pending_file_rename_operations, KeyValuePartialInformation, buffer, size, &size )) goto done;
201 if (info->Type != REG_MULTI_SZ) goto done;
202 if (size > sizeof(info)) size -= sizeof(WCHAR); /* remove terminating null (will be added back later) */
203 }
204 else
205 {
206 size = info_size;
207 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size + len1 + len2 + sizeof(WCHAR) ))) goto done;
208 }
209
210 memcpy( buffer + size, source_name.Buffer, len1 );
211 size += len1;
212 p = (WCHAR *)(buffer + size);
213 if (dest)
214 {
215 if (flags & MOVEFILE_REPLACE_EXISTING) *p++ = '!';
216 memcpy( p, dest_name.Buffer, len2 );
217 size += len2;
218 }
219 else
220 {
221 *p = 0;
222 size += sizeof(WCHAR);
223 }
224
225 /* add final null */
226 p = (WCHAR *)(buffer + size);
227 *p = 0;
228 size += sizeof(WCHAR);
229 rc = !NtSetValueKey( key, &pending_file_rename_operations, 0, REG_MULTI_SZ, buffer + info_size, size - info_size );
230
231 done:
232 RtlFreeUnicodeString( &source_name );
233 RtlFreeUnicodeString( &dest_name );
234 if (key) NtClose(key);
236 return rc;
237}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define L(x)
Definition: resources.c:13
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const char session_manager[]
Definition: install.c:5160
static char * dest
Definition: rtl.c:135
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define REG_MULTI_SZ
Definition: nt_native.h:1501
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Definition: cookie.c:202
Definition: copy.c:22
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:229
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by MoveFileWithProgressW().

◆ append_ext()

static WCHAR * append_ext ( const WCHAR name,
const WCHAR ext 
)
static

Definition at line 243 of file file.c.

244{
245 const WCHAR *p;
246 WCHAR *ret;
247 DWORD len;
248
249 if (!ext) return NULL;
250 p = wcsrchr( name, '.' );
251 if (p && !wcschr( p, '/' ) && !wcschr( p, '\\' )) return NULL;
252
253 len = lstrlenW( name ) + lstrlenW( ext );
254 if ((ret = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) )))
255 {
256 lstrcpyW( ret, name );
257 lstrcatW( ret, ext );
258 }
259 return ret;
260}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
#define wcschr
Definition: compat.h:17
#define wcsrchr
Definition: compat.h:16
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
static const WCHAR *const ext[]
Definition: module.c:53
return ret
Definition: mutex.c:146
GLenum GLsizei len
Definition: glext.h:6722
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
Definition: name.c:39

Referenced by SearchPathW().

◆ AreFileApisANSI()

BOOL WINAPI DECLSPEC_HOTPATCH AreFileApisANSI ( void  )

Definition at line 483 of file file.c.

484{
485 return !oem_file_apis;
486}
static BOOL oem_file_apis
Definition: file.c:70

Referenced by cmpStrAW(), FilenameA2W(), FilenameA2W_N(), FilenameU2A_FitOrFail(), and FilenameW2A_N().

◆ CancelIo()

BOOL WINAPI DECLSPEC_HOTPATCH CancelIo ( HANDLE  handle)

Definition at line 2994 of file file.c.

2995{
2997
2998 return set_ntstatus( NtCancelIoFile( handle, &io ) );
2999}
static __inline BOOL set_ntstatus(NTSTATUS status)
Definition: security.c:227
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4020

◆ CancelIoEx()

BOOL WINAPI DECLSPEC_HOTPATCH CancelIoEx ( HANDLE  handle,
LPOVERLAPPED  overlapped 
)

Definition at line 3005 of file file.c.

3006{
3008
3010}
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:81

Referenced by rpcrt4_conn_np_cancel_call().

◆ CancelSynchronousIo()

BOOL WINAPI DECLSPEC_HOTPATCH CancelSynchronousIo ( HANDLE  thread)

Definition at line 3016 of file file.c.

3017{
3019
3021}
static HANDLE thread
Definition: service.c:33
NTSYSAPI NTSTATUS WINAPI NtCancelSynchronousIoFile(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)

◆ ClearCommBreak()

BOOL WINAPI DECLSPEC_HOTPATCH ClearCommBreak ( HANDLE  handle)

Definition at line 4199 of file file.c.

4200{
4202}
BOOL WINAPI DECLSPEC_HOTPATCH EscapeCommFunction(HANDLE handle, DWORD func)
Definition: file.c:4283
#define CLRBREAK
Definition: winbase.h:265

◆ ClearCommError()

BOOL WINAPI DECLSPEC_HOTPATCH ClearCommError ( HANDLE  handle,
DWORD errors,
COMSTAT stat 
)

Definition at line 4208 of file file.c.

4209{
4211
4213 return FALSE;
4214
4215 TRACE( "status %#lx,%#lx, in %lu, out %lu, eof %d, wait %d\n", ss.Errors, ss.HoldReasons,
4216 ss.AmountInInQueue, ss.AmountInOutQueue, ss.EofReceived, ss.WaitForImmediate );
4217
4218 if (errors)
4219 {
4220 *errors = 0;
4221 if (ss.Errors & SERIAL_ERROR_BREAK) *errors |= CE_BREAK;
4222 if (ss.Errors & SERIAL_ERROR_FRAMING) *errors |= CE_FRAME;
4223 if (ss.Errors & SERIAL_ERROR_OVERRUN) *errors |= CE_OVERRUN;
4224 if (ss.Errors & SERIAL_ERROR_QUEUEOVERRUN) *errors |= CE_RXOVER;
4225 if (ss.Errors & SERIAL_ERROR_PARITY) *errors |= CE_RXPARITY;
4226 }
4227 if (stat)
4228 {
4229 stat->fCtsHold = !!(ss.HoldReasons & SERIAL_TX_WAITING_FOR_CTS);
4230 stat->fDsrHold = !!(ss.HoldReasons & SERIAL_TX_WAITING_FOR_DSR);
4231 stat->fRlsdHold = !!(ss.HoldReasons & SERIAL_TX_WAITING_FOR_DCD);
4232 stat->fXoffHold = !!(ss.HoldReasons & SERIAL_TX_WAITING_FOR_XON);
4233 stat->fXoffSent = !!(ss.HoldReasons & SERIAL_TX_WAITING_XOFF_SENT);
4234 stat->fEof = !!ss.EofReceived;
4235 stat->fTxim = !!ss.WaitForImmediate;
4236 stat->cbInQue = ss.AmountInInQueue;
4237 stat->cbOutQue = ss.AmountInOutQueue;
4238 }
4239 return TRUE;
4240}
#define TRUE
Definition: types.h:120
BOOL WINAPI DECLSPEC_HOTPATCH DeviceIoControl(HANDLE handle, DWORD code, void *in_buff, DWORD in_count, void *out_buff, DWORD out_count, DWORD *returned, OVERLAPPED *overlapped)
Definition: file.c:4246
#define ss
Definition: i386-dis.c:441
#define SERIAL_ERROR_QUEUEOVERRUN
Definition: ntddser.h:401
#define SERIAL_TX_WAITING_FOR_CTS
Definition: ntddser.h:419
#define SERIAL_TX_WAITING_FOR_XON
Definition: ntddser.h:422
#define SERIAL_ERROR_BREAK
Definition: ntddser.h:398
#define IOCTL_SERIAL_GET_COMMSTATUS
Definition: ntddser.h:54
#define SERIAL_TX_WAITING_FOR_DCD
Definition: ntddser.h:421
#define SERIAL_TX_WAITING_FOR_DSR
Definition: ntddser.h:420
#define SERIAL_ERROR_FRAMING
Definition: ntddser.h:399
#define SERIAL_ERROR_PARITY
Definition: ntddser.h:402
#define SERIAL_TX_WAITING_XOFF_SENT
Definition: ntddser.h:423
#define SERIAL_ERROR_OVERRUN
Definition: ntddser.h:400
#define TRACE(s)
Definition: solgame.cpp:4
Definition: stat.h:55
#define CE_BREAK
Definition: winbase.h:143
#define CE_OVERRUN
Definition: winbase.h:149
#define CE_RXPARITY
Definition: winbase.h:152
#define CE_RXOVER
Definition: winbase.h:151
#define CE_FRAME
Definition: winbase.h:145

◆ CompareFileTime()

INT WINAPI DECLSPEC_HOTPATCH CompareFileTime ( const FILETIME x,
const FILETIME y 
)

Definition at line 4003 of file file.c.

4004{
4005 if (!x || !y) return -1;
4006 if (x->dwHighDateTime > y->dwHighDateTime) return 1;
4007 if (x->dwHighDateTime < y->dwHighDateTime) return -1;
4008 if (x->dwLowDateTime > y->dwLowDateTime) return 1;
4009 if (x->dwLowDateTime < y->dwLowDateTime) return -1;
4010 return 0;
4011}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by test_CopyFile2(), and test_CopyFileA().

◆ contains_path()

static BOOL contains_path ( const WCHAR name)
inlinestatic

Definition at line 102 of file file.c.

103{
105 if (name[0] != '.') return FALSE;
106 if (name[1] == '/' || name[1] == '\\') return TRUE;
107 return (name[1] == '.' && (name[2] == '/' || name[2] == '\\'));
108}
@ RELATIVE_PATH
Definition: winternl.h:2518
NTSYSAPI RTL_PATH_TYPE NTAPI RtlDetermineDosPathNameType_U(_In_ PCWSTR Path)

Referenced by SearchPathW().

◆ copy_file()

static BOOL copy_file ( const WCHAR source,
const WCHAR dest,
COPYFILE2_EXTENDED_PARAMETERS *  params 
)
static

Definition at line 491 of file file.c.

492{
493 DWORD flags = params ? params->dwCopyFlags : 0;
494 BOOL *cancel_ptr = params ? params->pfCancel : NULL;
495 PCOPYFILE2_PROGRESS_ROUTINE progress = params ? params->pProgressRoutine : NULL;
496
497 static const int buffer_size = 65536;
498 HANDLE h1, h2;
501 DWORD count;
502 BOOL ret = FALSE;
503 char *buffer;
504
505 if (cancel_ptr)
506 FIXME("pfCancel is not supported\n");
507 if (progress)
508 FIXME("PCOPYFILE2_PROGRESS_ROUTINE is not supported\n");
509
510 if (!source || !dest)
511 {
513 return FALSE;
514 }
515 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, buffer_size )))
516 {
518 return FALSE;
519 }
520
521 TRACE("%s -> %s, %lx\n", debugstr_w(source), debugstr_w(dest), flags);
522
524 FIXME("COPY_FILE_RESTARTABLE is not supported\n");
525 if (flags & COPY_FILE_COPY_SYMLINK)
526 FIXME("COPY_FILE_COPY_SYMLINK is not supported\n");
528 FIXME("COPY_FILE_OPEN_SOURCE_FOR_WRITE is not supported\n");
529
532 {
533 WARN("Unable to open source %s\n", debugstr_w(source));
535 return FALSE;
536 }
537
539 {
540 WARN("GetFileInformationByHandle returned error for %s\n", debugstr_w(source));
542 CloseHandle( h1 );
543 return FALSE;
544 }
545
547 {
548 BOOL same_file = FALSE;
550 if (h2 != INVALID_HANDLE_VALUE)
551 {
552 same_file = is_same_file( h1, h2 );
553 CloseHandle( h2 );
554 }
555 if (same_file)
556 {
558 CloseHandle( h1 );
560 return FALSE;
561 }
562 }
563
566 info.FileAttributes, h1 )) == INVALID_HANDLE_VALUE)
567 {
568 WARN("Unable to open dest %s\n", debugstr_w(dest));
570 CloseHandle( h1 );
571 return FALSE;
572 }
573
574 while (ReadFile( h1, buffer, buffer_size, &count, NULL ) && count)
575 {
576 char *p = buffer;
577 while (count != 0)
578 {
579 DWORD res;
580 if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done;
581 p += res;
582 count -= res;
583 }
584 }
585 ret = TRUE;
586done:
587 /* Maintain the timestamp of source file to destination file and read-only attribute */
588 info.FileAttributes &= FILE_ATTRIBUTE_READONLY;
591 CloseHandle( h1 );
592 CloseHandle( h2 );
593 if (ret) SetLastError( 0 );
594 return ret;
595}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
cd_progress_ptr progress
Definition: cdjpeg.h:152
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CloseHandle
Definition: compat.h:739
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI DECLSPEC_HOTPATCH WriteFile(HANDLE file, LPCVOID buffer, DWORD count, LPDWORD result, LPOVERLAPPED overlapped)
Definition: file.c:3896
static BOOL is_same_file(HANDLE h1, HANDLE h2)
Definition: file.c:469
@ FileBasicInformation
Definition: from_kernel.h:65
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLenum const GLfloat * params
Definition: glext.h:5645
#define debugstr_w
Definition: kernel32.h:32
#define CREATE_ALWAYS
Definition: disk.h:72
#define CREATE_NEW
Definition: disk.h:69
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3096
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define GENERIC_WRITE
Definition: nt_native.h:90
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
#define COPY_FILE_FAIL_IF_EXISTS
Definition: winbase.h:238
#define COPY_FILE_RESTARTABLE
Definition: winbase.h:239
#define COPY_FILE_OPEN_SOURCE_FOR_WRITE
Definition: winbase.h:240
#define ERROR_SHARING_VIOLATION
Definition: winerror.h:258

Referenced by CopyFile2(), and CopyFileExW().

◆ copy_filename()

static DWORD copy_filename ( const WCHAR name,
WCHAR buffer,
DWORD  len 
)
static

Definition at line 361 of file file.c.

362{
363 UINT ret = lstrlenW( name ) + 1;
364 if (buffer && len >= ret)
365 {
366 lstrcpyW( buffer, name );
367 ret--;
368 }
369 return ret;
370}
unsigned int UINT
Definition: ndis.h:50

Referenced by GetSystemDirectoryW(), GetSystemWow64Directory2W(), GetSystemWow64DirectoryW(), and GetWindowsDirectoryW().

◆ copy_filename_WtoA()

static DWORD copy_filename_WtoA ( LPCWSTR  nameW,
LPSTR  buffer,
DWORD  len 
)
static

Definition at line 378 of file file.c.

379{
381 DWORD ret;
382
384
386 if (buffer && ret <= len)
387 {
389
390 str.Buffer = buffer;
391 str.MaximumLength = min( len, UNICODE_STRING_MAX_CHARS );
392 if (oem_file_apis)
394 else
396 ret = str.Length; /* length without terminating 0 */
397 }
398 return ret;
399}
static const WCHAR nameW[]
Definition: main.c:49
WCHAR strW[12]
Definition: clipboard.c:2025
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_STRING_MAX_CHARS
const WCHAR * str
#define RtlUnicodeStringToOemSize(STRING)
#define RtlUnicodeStringToAnsiSize(String)
Definition: rtlfuncs.h:1022

Referenced by GetCurrentDirectoryA(), GetFullPathNameA(), GetLongPathNameA(), GetSystemDirectoryA(), GetSystemWow64Directory2A(), GetSystemWow64DirectoryA(), GetTempPathA(), GetWindowsDirectoryA(), and SearchPathA().

◆ CopyFile2()

HRESULT WINAPI CopyFile2 ( const WCHAR source,
const WCHAR dest,
COPYFILE2_EXTENDED_PARAMETERS *  params 
)

Definition at line 600 of file file.c.

601{
603}
static BOOL copy_file(const WCHAR *source, const WCHAR *dest, COPYFILE2_EXTENDED_PARAMETERS *params)
Definition: file.c:491
#define S_OK
Definition: intsafe.h:52
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:211

◆ CopyFileExW()

BOOL WINAPI CopyFileExW ( const WCHAR source,
const WCHAR dest,
LPPROGRESS_ROUTINE  progress,
void param,
BOOL cancel_ptr,
DWORD  flags 
)

Definition at line 609 of file file.c.

611{
612 COPYFILE2_EXTENDED_PARAMETERS params;
613
614 if (progress)
615 FIXME("LPPROGRESS_ROUTINE is not supported\n");
616 if (cancel_ptr)
617 FIXME("cancel_ptr is not supported\n");
618
619 params.dwSize = sizeof(params);
620 params.dwCopyFlags = flags;
621 params.pProgressRoutine = NULL;
622 params.pvCallbackContext = NULL;
623 params.pfCancel = NULL;
624
625 return copy_file( source, dest, &params );
626}

Referenced by CopyFileW(), MoveFileWithProgressW(), and transfer_file_local().

◆ CopyFileW()

BOOL WINAPI DECLSPEC_HOTPATCH CopyFileW ( const WCHAR source,
const WCHAR dest,
BOOL  fail_if_exists 
)

Definition at line 632 of file file.c.

633{
634 return CopyFileExW( source, dest, NULL, NULL, NULL, fail_if_exists ? COPY_FILE_FAIL_IF_EXISTS : 0 );
635}
BOOL WINAPI CopyFileExW(const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUTINE progress, void *param, BOOL *cancel_ptr, DWORD flags)
Definition: file.c:609

Referenced by test_CopyFileW().

◆ CreateDirectoryA()

BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryA ( LPCSTR  path,
LPSECURITY_ATTRIBUTES  sa 
)

Definition at line 641 of file file.c.

642{
643 WCHAR *pathW;
644
645 if (!(pathW = file_name_AtoW( path, FALSE ))) return FALSE;
646 return CreateDirectoryW( pathW, sa );
647}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
WCHAR * file_name_AtoW(LPCSTR name, BOOL alloc)
Definition: file.c:411
BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sa)
Definition: file.c:653

Referenced by test_CreateFileA(), test_DeleteFileA(), test_file_disposition_information(), test_FindFirstFile_wildcards(), test_FindFirstFileA(), test_FindFirstFileExA(), test_MoveFileA(), and test_RemoveDirectory().

◆ CreateDirectoryExW()

BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryExW ( LPCWSTR  template,
LPCWSTR  path,
LPSECURITY_ATTRIBUTES  sa 
)

Definition at line 688 of file file.c.

690{
691 return CreateDirectoryW( path, sa );
692}

◆ CreateDirectoryW()

BOOL WINAPI DECLSPEC_HOTPATCH CreateDirectoryW ( LPCWSTR  path,
LPSECURITY_ATTRIBUTES  sa 
)

Definition at line 653 of file file.c.

654{
656 UNICODE_STRING nt_name;
660
661 TRACE( "%s\n", debugstr_w(path) );
662
663 if (!RtlDosPathNameToNtPathName_U( path, &nt_name, NULL, NULL ))
664 {
666 return FALSE;
667 }
668 attr.Length = sizeof(attr);
669 attr.RootDirectory = 0;
670 attr.Attributes = OBJ_CASE_INSENSITIVE;
671 attr.ObjectName = &nt_name;
672 attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
673 attr.SecurityQualityOfService = NULL;
674
679
680 RtlFreeUnicodeString( &nt_name );
681 return set_ntstatus( status );
682}
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
Definition: ps.c:97

Referenced by CreateDirectoryA(), CreateDirectoryExW(), delete_file_test(), test_CreateFile2(), test_CreateFileW(), test_DeleteFileW(), test_file_link_information(), test_file_rename_information(), and test_junction_points().

◆ CreateFile2()

HANDLE WINAPI DECLSPEC_HOTPATCH CreateFile2 ( LPCWSTR  name,
DWORD  access,
DWORD  sharing,
DWORD  creation,
CREATEFILE2_EXTENDED_PARAMETERS params 
)

Definition at line 698 of file file.c.

700{
701 static const DWORD attributes_mask = FILE_ATTRIBUTE_READONLY |
710 static const DWORD flags_mask = FILE_FLAG_BACKUP_SEMANTICS |
720
721 LPSECURITY_ATTRIBUTES sa = params ? params->lpSecurityAttributes : NULL;
722 HANDLE template = params ? params->hTemplateFile : NULL;
723 DWORD attributes = params ? params->dwFileAttributes : 0;
724 DWORD flags = params ? params->dwFileFlags : 0;
725
726 TRACE( "%s %#lx %#lx %#lx %p", debugstr_w(name), access, sharing, creation, params );
727 if (params) FIXME( "Ignoring extended parameters %p\n", params );
728
729 if (attributes & ~attributes_mask) FIXME( "unsupported attributes %#lx\n", attributes );
730 if (flags & ~flags_mask) FIXME( "unsupported flags %#lx\n", flags );
731 attributes &= attributes_mask;
732 flags &= flags_mask;
733
734 return CreateFileW( name, access, sharing, sa, creation, flags | attributes, template );
735}
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define FILE_FLAG_NO_BUFFERING
Definition: disk.h:45
#define FILE_FLAG_POSIX_SEMANTICS
Definition: disk.h:40
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_NO_RECALL
Definition: disk.h:38
#define FILE_FLAG_RANDOM_ACCESS
Definition: disk.h:44
#define FILE_FLAG_DELETE_ON_CLOSE
Definition: disk.h:42
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
#define FILE_FLAG_WRITE_THROUGH
Definition: disk.h:47
static ULONG POBJECT_ATTRIBUTES PIO_STATUS_BLOCK ULONG sharing
Definition: pipe.c:70
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_OFFLINE
Definition: nt_native.h:712
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_ATTRIBUTE_TEMPORARY
Definition: nt_native.h:708
#define FILE_ATTRIBUTE_ENCRYPTED
Definition: ntifs_ex.h:385
#define FILE_ATTRIBUTE_INTEGRITY_STREAM

Referenced by win32_open64_file_func(), win32_open64_file_funcA(), win32_open64_file_funcW(), and win32_open_file_func().

◆ CreateFileA()

HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileA ( LPCSTR  name,
DWORD  access,
DWORD  sharing,
LPSECURITY_ATTRIBUTES  sa,
DWORD  creation,
DWORD  attributes,
HANDLE  template 
)

Definition at line 741 of file file.c.

744{
745 WCHAR *nameW;
746
747 if ((GetVersion() & 0x80000000) && IsBadStringPtrA( name, -1 )) return INVALID_HANDLE_VALUE;
749 return CreateFileW( nameW, access, sharing, sa, creation, attributes, template );
750}
BOOL NTAPI IsBadStringPtrA(IN LPCSTR lpsz, IN UINT_PTR ucchMax)
Definition: except.c:989
DWORD WINAPI GetVersion(void)
Definition: version.c:1458

◆ CreateFileW()

HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileW ( LPCWSTR  filename,
DWORD  access,
DWORD  sharing,
LPSECURITY_ATTRIBUTES  sa,
DWORD  creation,
DWORD  attributes,
HANDLE  template 
)

Definition at line 778 of file file.c.

781{
786 HANDLE ret;
787 const WCHAR *vxd_name = NULL;
789
790 static const UINT nt_disposition[5] =
791 {
792 FILE_CREATE, /* CREATE_NEW */
793 FILE_OVERWRITE_IF, /* CREATE_ALWAYS */
794 FILE_OPEN, /* OPEN_EXISTING */
795 FILE_OPEN_IF, /* OPEN_ALWAYS */
796 FILE_OVERWRITE /* TRUNCATE_EXISTING */
797 };
798
799
800 /* sanity checks */
801
802 if (!filename || !filename[0])
803 {
806 }
807
808 TRACE( "%s %s%s%s%s%s%s%s creation %ld attributes 0x%lx\n", debugstr_w(filename),
809 (access & GENERIC_READ) ? "GENERIC_READ " : "",
810 (access & GENERIC_WRITE) ? "GENERIC_WRITE " : "",
811 (access & GENERIC_EXECUTE) ? "GENERIC_EXECUTE " : "",
812 !access ? "QUERY_ACCESS " : "",
813 (sharing & FILE_SHARE_READ) ? "FILE_SHARE_READ " : "",
814 (sharing & FILE_SHARE_WRITE) ? "FILE_SHARE_WRITE " : "",
815 (sharing & FILE_SHARE_DELETE) ? "FILE_SHARE_DELETE " : "",
816 creation, attributes);
817
818 if ((GetVersion() & 0x80000000) && !wcsncmp( filename, L"\\\\.\\", 4 ) &&
820 wcsnicmp( filename + 4, L"PIPE\\", 5 ) &&
821 wcsnicmp( filename + 4, L"MAILSLOT\\", 9 ))
822 {
823 vxd_name = filename + 4;
824 if (!creation) creation = OPEN_EXISTING;
825 }
826
827 if (creation < CREATE_NEW || creation > TRUNCATE_EXISTING)
828 {
831 }
832
834 {
837 }
838
839 /* now call NtCreateFile */
840
841 if (attributes & FILE_FLAG_DELETE_ON_CLOSE)
842 access |= DELETE;
843
844 attr.Length = sizeof(attr);
845 attr.RootDirectory = 0;
846 attr.Attributes = OBJ_CASE_INSENSITIVE;
847 attr.ObjectName = &nameW;
848 attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
849 if (attributes & SECURITY_SQOS_PRESENT)
850 {
851 qos.Length = sizeof(qos);
852 qos.ImpersonationLevel = (attributes >> 16) & 0x3;
854 qos.EffectiveOnly = (attributes & SECURITY_EFFECTIVE_ONLY) != 0;
855 attr.SecurityQualityOfService = &qos;
856 }
857 else
858 attr.SecurityQualityOfService = NULL;
859
860 if (sa && sa->bInheritHandle) attr.Attributes |= OBJ_INHERIT;
861
864 nt_disposition[creation - CREATE_NEW],
865 get_nt_file_options( attributes ), NULL, 0 );
866 if (status)
867 {
868 if (vxd_name && vxd_name[0])
869 {
870 static HANDLE (*vxd_open)(LPCWSTR,DWORD,SECURITY_ATTRIBUTES*);
871 if (!vxd_open) vxd_open = (void *)GetProcAddress( GetModuleHandleW(L"krnl386.exe16"),
872 "__wine_vxd_open" );
873 if (vxd_open && (ret = vxd_open( vxd_name, access, sa ))) goto done;
874 }
875
876 WARN("Unable to create file %s (status %lx)\n", debugstr_w(filename), status);
878
879 /* In the case file creation was rejected due to CREATE_NEW flag
880 * was specified and file with that name already exists, correct
881 * last error is ERROR_FILE_EXISTS and not ERROR_ALREADY_EXISTS.
882 * Note: RtlNtStatusToDosError is not the subject to blame here.
883 */
886 else
888 }
889 else
890 {
891 if ((creation == CREATE_ALWAYS && io.Information == FILE_OVERWRITTEN) ||
892 (creation == OPEN_ALWAYS && io.Information == FILE_OPENED))
894 else
895 SetLastError( 0 );
896 }
898
899 done:
901 TRACE("returning %p\n", ret);
902 return ret;
903}
#define wcsnicmp
Definition: compat.h:14
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static UINT get_nt_file_options(DWORD attributes)
Definition: file.c:752
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_OVERWRITE_IF
Definition: from_kernel.h:58
#define FILE_OVERWRITE
Definition: from_kernel.h:57
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define OBJ_INHERIT
Definition: winternl.h:225
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
const char * filename
Definition: ioapi.h:137
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define TRUNCATE_EXISTING
Definition: disk.h:71
#define OPEN_ALWAYS
Definition: disk.h:70
NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U(_In_ PCWSTR Name)
#define FILE_ATTRIBUTE_VALID_FLAGS
Definition: nt_native.h:714
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_OVERWRITTEN
Definition: nt_native.h:771
#define DELETE
Definition: nt_native.h:57
#define FILE_OPENED
Definition: nt_native.h:769
#define DWORD
Definition: nt_native.h:44
#define GENERIC_EXECUTE
Definition: nt_native.h:91
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
PVOID HANDLE
Definition: typedefs.h:73
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define SECURITY_SQOS_PRESENT
Definition: winbase.h:582
#define SECURITY_EFFECTIVE_ONLY
Definition: winbase.h:581
#define SECURITY_CONTEXT_TRACKING
Definition: winbase.h:580
#define ERROR_FILE_EXISTS
Definition: winerror.h:288
#define SECURITY_STATIC_TRACKING
Definition: setypes.h:104
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ CreateHardLinkA()

BOOL WINAPI DECLSPEC_HOTPATCH CreateHardLinkA ( const char dest,
const char source,
SECURITY_ATTRIBUTES attr 
)

Definition at line 909 of file file.c.

911{
912 WCHAR *sourceW, *destW;
913 BOOL res;
914
915 if (!(sourceW = file_name_AtoW( source, TRUE ))) return FALSE;
916 if (!(destW = file_name_AtoW( dest, TRUE )))
917 {
919 return FALSE;
920 }
921 res = CreateHardLinkW( destW, sourceW, attr );
923 HeapFree( GetProcessHeap(), 0, destW );
924 return res;
925}
BOOL WINAPI CreateHardLinkW(LPCWSTR dest, LPCWSTR source, SECURITY_ATTRIBUTES *sec_attr)
Definition: file.c:931
static const WCHAR sourceW[]
Definition: jsregexp.c:37

◆ CreateHardLinkW()

BOOL WINAPI CreateHardLinkW ( LPCWSTR  dest,
LPCWSTR  source,
SECURITY_ATTRIBUTES sec_attr 
)

Definition at line 931 of file file.c.

932{
933 UNICODE_STRING ntDest, ntSource;
937 BOOL ret = FALSE;
938 HANDLE file;
939 ULONG size;
940
941 TRACE( "(%s, %s, %p)\n", debugstr_w(dest), debugstr_w(source), sec_attr );
942
943 ntDest.Buffer = ntSource.Buffer = NULL;
944 if (!RtlDosPathNameToNtPathName_U( dest, &ntDest, NULL, NULL ) ||
946 {
948 goto done;
949 }
950
952 if (!(info = HeapAlloc( GetProcessHeap(), 0, size )))
953 {
955 goto done;
956 }
957
961 goto done;
962
963 info->ReplaceIfExists = FALSE;
964 info->RootDirectory = NULL;
965 info->FileNameLength = ntDest.Length;
966 memcpy( info->FileName, ntDest.Buffer, ntDest.Length );
968 NtClose( file );
969
970done:
971 RtlFreeUnicodeString( &ntSource );
972 RtlFreeUnicodeString( &ntDest );
974 return ret;
975}
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
@ FileLinkInformation
Definition: from_kernel.h:72
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3953
#define offsetof(TYPE, MEMBER)
Definition: fci.c:127
uint32_t ULONG
Definition: typedefs.h:59

Referenced by CreateHardLinkA().

◆ CreateSymbolicLinkW()

BOOLEAN WINAPI CreateSymbolicLinkW ( LPCWSTR  link,
LPCWSTR  target,
DWORD  flags 
)

Definition at line 981 of file file.c.

982{
983 FIXME( "(%s %s %ld): stub\n", debugstr_w(link), debugstr_w(target), flags );
984 return TRUE;
985}
const WCHAR * link
Definition: db.cpp:997
GLenum target
Definition: glext.h:7315

◆ DeleteFileA()

◆ DeleteFileW()

BOOL WINAPI DECLSPEC_HOTPATCH DeleteFileW ( LPCWSTR  path)

Definition at line 1003 of file file.c.

1004{
1008 HANDLE hFile;
1010
1011 TRACE( "%s\n", debugstr_w(path) );
1012
1014 {
1016 return FALSE;
1017 }
1018
1019 attr.Length = sizeof(attr);
1020 attr.RootDirectory = 0;
1021 attr.Attributes = OBJ_CASE_INSENSITIVE;
1022 attr.ObjectName = &nameW;
1023 attr.SecurityDescriptor = NULL;
1024 attr.SecurityQualityOfService = NULL;
1025
1030
1032 return set_ntstatus( status );
1033}
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by _wremove(), _wtempnam(), _wunlink(), delete_object(), DeleteFileA(), MoveFileWithProgressW(), open_file_test(), processFile(), ReplaceFileW(), test_CopyFile2(), test_CopyFileW(), test_CreateFile2(), test_CreateFileW(), test_DeleteFileW(), test_file_link_information(), test_file_rename_information(), test_junction_points(), test_MoveFileW(), test_NtCreateFile(), test_readonly(), and test_ReplaceFileW().

◆ DeviceIoControl()

BOOL WINAPI DECLSPEC_HOTPATCH DeviceIoControl ( HANDLE  handle,
DWORD  code,
void in_buff,
DWORD  in_count,
void out_buff,
DWORD  out_count,
DWORD returned,
OVERLAPPED overlapped 
)

Definition at line 4246 of file file.c.

4249{
4250 IO_STATUS_BLOCK iosb, *piosb = &iosb;
4251 void *cvalue = NULL;
4252 HANDLE event = 0;
4254
4255 TRACE( "(%p,%lx,%p,%ld,%p,%ld,%p,%p)\n",
4256 handle, code, in_buff, in_count, out_buff, out_count, returned, overlapped );
4257
4258 if (overlapped)
4259 {
4260 piosb = (IO_STATUS_BLOCK *)overlapped;
4261 if (!((ULONG_PTR)overlapped->hEvent & 1)) cvalue = overlapped;
4262 event = overlapped->hEvent;
4263 overlapped->Internal = STATUS_PENDING;
4264 overlapped->InternalHigh = 0;
4265 }
4266
4268 status = NtFsControlFile( handle, event, NULL, cvalue, piosb, code,
4269 in_buff, in_count, out_buff, out_count );
4270 else
4271 status = NtDeviceIoControlFile( handle, event, NULL, cvalue, piosb, code,
4272 in_buff, in_count, out_buff, out_count );
4273
4274 if (returned && !NT_ERROR(status)) *returned = piosb->Information;
4275 if (status == STATUS_PENDING || !NT_SUCCESS( status )) return set_ntstatus( status );
4276 return TRUE;
4277}
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
struct _cl_event * event
Definition: glext.h:7739
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
static UINT UINT * out_count
Definition: clipboard.c:31
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FILE_DEVICE_FILE_SYSTEM
Definition: winioctl.h:54
Definition: inflate.c:139
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define HIWORD(l)
Definition: typedefs.h:247
#define NT_ERROR(Status)
Definition: umtypes.h:106

Referenced by ClearCommError(), EscapeCommFunction(), GetCommMask(), GetCommModemStatus(), GetCommProperties(), GetCommState(), GetCommTimeouts(), PurgeComm(), SetCommMask(), SetCommState(), SetCommTimeouts(), SetupComm(), test_junction_points(), TransmitCommChar(), and WaitCommEvent().

◆ dump_dcb()

static void dump_dcb ( const DCB dcb)
static

Definition at line 4186 of file file.c.

4187{
4188 TRACE( "size=%d rate=%ld fParity=%d Parity=%d stopbits=%d %sIXON %sIXOFF CTS=%d RTS=%d DSR=%d DTR=%d %sCRTSCTS\n",
4189 dcb->ByteSize, dcb->BaudRate, dcb->fParity, dcb->Parity,
4190 (dcb->StopBits == ONESTOPBIT) ? 1 : (dcb->StopBits == TWOSTOPBITS) ? 2 : 0,
4191 dcb->fOutX ? "" : "~", dcb->fInX ? "" : "~",
4192 dcb->fOutxCtsFlow, dcb->fRtsControl, dcb->fOutxDsrFlow, dcb->fDtrControl,
4193 (dcb->fOutxCtsFlow || dcb->fRtsControl == RTS_CONTROL_HANDSHAKE) ? "" : "~" );
4194}
#define TWOSTOPBITS
Definition: winbase.h:493
#define ONESTOPBIT
Definition: winbase.h:491
#define RTS_CONTROL_HANDSHAKE
Definition: winbase.h:574

Referenced by GetCommState(), and SetCommState().

◆ EscapeCommFunction()

BOOL WINAPI DECLSPEC_HOTPATCH EscapeCommFunction ( HANDLE  handle,
DWORD  func 
)

Definition at line 4283 of file file.c.

4284{
4285 static const DWORD ioctls[] =
4286 {
4287 0,
4288 IOCTL_SERIAL_SET_XOFF, /* SETXOFF */
4289 IOCTL_SERIAL_SET_XON, /* SETXON */
4290 IOCTL_SERIAL_SET_RTS, /* SETRTS */
4291 IOCTL_SERIAL_CLR_RTS, /* CLRRTS */
4292 IOCTL_SERIAL_SET_DTR, /* SETDTR */
4293 IOCTL_SERIAL_CLR_DTR, /* CLRDTR */
4294 IOCTL_SERIAL_RESET_DEVICE, /* RESETDEV */
4295 IOCTL_SERIAL_SET_BREAK_ON, /* SETBREAK */
4296 IOCTL_SERIAL_SET_BREAK_OFF /* CLRBREAK */
4297 };
4298
4299 if (func >= ARRAY_SIZE(ioctls) || !ioctls[func])
4300 {
4302 return FALSE;
4303 }
4304 return DeviceIoControl( handle, ioctls[func], NULL, 0, NULL, 0, NULL, NULL );
4305}
#define ARRAY_SIZE(A)
Definition: main.h:20
GLenum func
Definition: glext.h:6028
#define IOCTL_SERIAL_SET_XOFF
Definition: ntddser.h:108
#define IOCTL_SERIAL_RESET_DEVICE
Definition: ntddser.h:80
#define IOCTL_SERIAL_SET_BREAK_OFF
Definition: ntddser.h:86
#define IOCTL_SERIAL_SET_XON
Definition: ntddser.h:110
#define IOCTL_SERIAL_CLR_DTR
Definition: ntddser.h:44
#define IOCTL_SERIAL_CLR_RTS
Definition: ntddser.h:46
#define IOCTL_SERIAL_SET_DTR
Definition: ntddser.h:90
#define IOCTL_SERIAL_SET_BREAK_ON
Definition: ntddser.h:84
#define IOCTL_SERIAL_SET_RTS
Definition: ntddser.h:102

Referenced by ClearCommBreak(), and SetCommBreak().

◆ file_name_AtoW()

WCHAR * file_name_AtoW ( LPCSTR  name,
BOOL  alloc 
)

Definition at line 411 of file file.c.

412{
414 UNICODE_STRING strW, *pstrW;
416
418 pstrW = alloc ? &strW : &NtCurrentTeb()->StaticUnicodeString;
419 if (oem_file_apis)
421 else
423 if (status == STATUS_SUCCESS) return pstrW->Buffer;
424
427 else
429 return NULL;
430}
#define NtCurrentTeb
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define alloc
Definition: rosglue.h:13
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:386

Referenced by CreateDirectoryA(), CreateFileA(), CreateHardLinkA(), CreateProcessInternalA(), DeleteFileA(), FindFirstChangeNotificationA(), FindFirstFileExA(), GetCompressedFileSizeA(), GetDiskFreeSpaceA(), GetDiskFreeSpaceExA(), GetDriveTypeA(), GetFileAttributesA(), GetFileAttributesExA(), GetFullPathNameA(), GetLongPathNameA(), GetModuleHandleExA(), GetTempFileNameA(), GetVolumeInformationA(), LoadLibraryExA(), NeedCurrentDirectoryForExePathA(), RemoveDirectoryA(), SearchPathA(), SetCurrentDirectoryA(), and SetFileAttributesA().

◆ file_name_WtoA()

DWORD file_name_WtoA ( LPCWSTR  src,
INT  srclen,
LPSTR  dest,
INT  destlen 
)

Definition at line 438 of file file.c.

439{
440 DWORD ret;
441
442 if (srclen < 0) srclen = lstrlenW( src ) + 1;
443 if (!destlen)
444 {
445 if (oem_file_apis)
446 {
448 strW.Buffer = (WCHAR *)src;
449 strW.Length = srclen * sizeof(WCHAR);
451 }
452 else
454 }
455 else
456 {
457 if (oem_file_apis)
458 RtlUnicodeToOemN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
459 else
460 RtlUnicodeToMultiByteN( dest, destlen, &ret, src, srclen * sizeof(WCHAR) );
461 }
462 return ret;
463}
GLenum src
Definition: glext.h:6340
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToOemN(_Out_ PCHAR OemString, _In_ ULONG OemSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:263
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteN(_Out_ PCHAR MbString, _In_ ULONG MbSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:107
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteSize(_Out_ PULONG MbSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:145

Referenced by FindFirstFileExA(), FindNextFileA(), GetFinalPathNameByHandleA(), GetFullPathNameA(), GetMappedFileNameA(), GetModuleFileNameA(), GetTempFileNameA(), and GetVolumeInformationA().

◆ FileTimeToLocalFileTime()

BOOL WINAPI DECLSPEC_HOTPATCH FileTimeToLocalFileTime ( const FILETIME utc,
FILETIME local 
)

Definition at line 4017 of file file.c.

4018{
4020}
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
#define local
Definition: zutil.h:30
NTSYSAPI NTSTATUS NTAPI RtlSystemTimeToLocalTime(_In_ PLARGE_INTEGER SystemTime, _Out_ PLARGE_INTEGER LocalTime)

◆ FileTimeToSystemTime()

BOOL WINAPI DECLSPEC_HOTPATCH FileTimeToSystemTime ( const FILETIME ft,
SYSTEMTIME systime 
)

Definition at line 4026 of file file.c.

4027{
4029 const LARGE_INTEGER *li = (const LARGE_INTEGER *)ft;
4030
4031 if (li->QuadPart < 0)
4032 {
4034 return FALSE;
4035 }
4037 systime->wYear = tf.Year;
4038 systime->wMonth = tf.Month;
4039 systime->wDay = tf.Day;
4040 systime->wHour = tf.Hour;
4041 systime->wMinute = tf.Minute;
4042 systime->wSecond = tf.Second;
4043 systime->wMilliseconds = tf.Milliseconds;
4044 systime->wDayOfWeek = tf.Weekday;
4045 return TRUE;
4046}
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
HFONT tf
Definition: icontest.c:17
WORD wYear
Definition: winbase.h:946
WORD wMilliseconds
Definition: winbase.h:953
WORD wMonth
Definition: winbase.h:947
WORD wHour
Definition: winbase.h:950
WORD wSecond
Definition: winbase.h:952
WORD wMinute
Definition: winbase.h:951
WORD wDay
Definition: winbase.h:949
WORD wDayOfWeek
Definition: winbase.h:948
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by GetLocalTime(), and GetSystemTime().

◆ find_actctx_dllpath()

static NTSTATUS find_actctx_dllpath ( const WCHAR name,
WCHAR **  path 
)
static

Definition at line 269 of file file.c.

270{
271 ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info;
272 ACTCTX_SECTION_KEYED_DATA data;
275 SIZE_T needed, size = 1024;
276 WCHAR *p;
277
279 data.cbSize = sizeof(data);
280 status = RtlFindActivationContextSectionString( FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
281 ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
282 &nameW, &data );
283 if (status != STATUS_SUCCESS) return status;
284
285 for (;;)
286 {
287 if (!(info = RtlAllocateHeap( GetProcessHeap(), 0, size )))
288 {
290 goto done;
291 }
292 status = RtlQueryInformationActivationContext( 0, data.hActCtx, &data.ulAssemblyRosterIndex,
293 AssemblyDetailedInformationInActivationContext,
294 info, size, &needed );
295 if (status == STATUS_SUCCESS) break;
296 if (status != STATUS_BUFFER_TOO_SMALL) goto done;
298 size = needed;
299 /* restart with larger buffer */
300 }
301
302 if (!info->lpAssemblyManifestPath)
303 {
305 goto done;
306 }
307
308 if ((p = wcsrchr( info->lpAssemblyManifestPath, '\\' )))
309 {
310 DWORD dirlen = info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
311
312 p++;
313 if (!dirlen ||
314 CompareStringOrdinal( p, dirlen, info->lpAssemblyDirectoryName, dirlen, TRUE ) != CSTR_EQUAL ||
315 wcsicmp( p + dirlen, L".manifest" ))
316 {
317 /* manifest name does not match directory name, so it's not a global
318 * windows/winsxs manifest; use the manifest directory name instead */
319 dirlen = p - info->lpAssemblyManifestPath;
320 needed = (dirlen + 1) * sizeof(WCHAR);
321 if (!(*path = p = HeapAlloc( GetProcessHeap(), 0, needed )))
322 {
324 goto done;
325 }
326 memcpy( p, info->lpAssemblyManifestPath, dirlen * sizeof(WCHAR) );
327 *(p + dirlen) = 0;
328 goto done;
329 }
330 }
331
332 if (!info->lpAssemblyDirectoryName)
333 {
335 goto done;
336 }
337
338 needed = sizeof(L"C:\\windows\\winsxs\\") + info->ulAssemblyDirectoryNameLength + sizeof(WCHAR);
339
340 if (!(*path = p = RtlAllocateHeap( GetProcessHeap(), 0, needed )))
341 {
343 goto done;
344 }
345 lstrcpyW( p, L"C:\\windows\\winsxs\\" );
346 p += lstrlenW(p);
347 memcpy( p, info->lpAssemblyDirectoryName, info->ulAssemblyDirectoryNameLength );
348 p += info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
349 *p++ = '\\';
350 *p = 0;
351done:
354 return status;
355}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define wcsicmp
Definition: compat.h:15
INT WINAPI DECLSPEC_HOTPATCH CompareStringOrdinal(const WCHAR *str1, INT len1, const WCHAR *str2, INT len2, BOOL ignore_case)
Definition: locale.c:4886
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
NTSYSAPI NTSTATUS WINAPI RtlFindActivationContextSectionString(ULONG, const GUID *, ULONG, const UNICODE_STRING *, PVOID)
Definition: actctx.c:5874
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5384
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5572
#define STATUS_SXS_KEY_NOT_FOUND
Definition: ntstatus.h:1389
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CSTR_EQUAL
Definition: winnls.h:476

Referenced by SearchPathW().

◆ FindClose()

BOOL WINAPI DECLSPEC_HOTPATCH FindClose ( HANDLE  handle)

Definition at line 1525 of file file.c.

1526{
1528
1530 {
1532 return FALSE;
1533 }
1534
1535 __TRY
1536 {
1537 if (info->magic == FIND_FIRST_MAGIC)
1538 {
1540 if (info->magic == FIND_FIRST_MAGIC) /* in case someone else freed it in the meantime */
1541 {
1542 info->magic = 0;
1543 if (info->handle) CloseHandle( info->handle );
1544 info->handle = 0;
1545 RtlFreeUnicodeString( &info->path );
1546 info->data_pos = 0;
1547 info->data_len = 0;
1549 info->cs.DebugInfo->Spare[0] = 0;
1551 HeapFree( GetProcessHeap(), 0, info );
1552 }
1553 }
1554 }
1556 {
1557 WARN( "illegal handle %p\n", handle );
1559 return FALSE;
1560 }
1561 __ENDTRY
1562
1563 return TRUE;
1564}
#define __TRY
Definition: compat.h:80
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define FIND_FIRST_MAGIC
Definition: file.c:63
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by FindFirstFileExW(), GetLongPathNameW(), GetShortPathNameW(), test__lcreat(), test_filemodeT(), test_FindFirstFile_wildcards(), test_FindFirstFileA(), test_FindFirstFileExA(), test_FindNextFileA(), and test_MoveFileA().

◆ FindCloseChangeNotification()

BOOL WINAPI DECLSPEC_HOTPATCH FindCloseChangeNotification ( HANDLE  handle)

Definition at line 1039 of file file.c.

1040{
1041 return CloseHandle( handle );
1042}

◆ FindFirstChangeNotificationA()

HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstChangeNotificationA ( LPCSTR  path,
BOOL  subtree,
DWORD  filter 
)

Definition at line 1048 of file file.c.

1049{
1050 WCHAR *pathW;
1051
1052 if (!(pathW = file_name_AtoW( path, FALSE ))) return INVALID_HANDLE_VALUE;
1053 return FindFirstChangeNotificationW( pathW, subtree, filter );
1054}
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstChangeNotificationW(LPCWSTR path, BOOL subtree, DWORD filter)
Definition: file.c:1067
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ FindFirstChangeNotificationW()

HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstChangeNotificationW ( LPCWSTR  path,
BOOL  subtree,
DWORD  filter 
)

Definition at line 1067 of file file.c.

1068{
1069 UNICODE_STRING nt_name;
1073
1074 TRACE( "%s %d %lx\n", debugstr_w(path), subtree, filter );
1075
1076 if (!RtlDosPathNameToNtPathName_U( path, &nt_name, NULL, NULL ))
1077 {
1079 return handle;
1080 }
1081
1082 attr.Length = sizeof(attr);
1083 attr.RootDirectory = 0;
1084 attr.Attributes = OBJ_CASE_INSENSITIVE;
1085 attr.ObjectName = &nt_name;
1086 attr.SecurityDescriptor = NULL;
1087 attr.SecurityQualityOfService = NULL;
1088
1092 RtlFreeUnicodeString( &nt_name );
1093
1095
1097 if (status != STATUS_PENDING)
1098 {
1099 NtClose( handle );
1101 return INVALID_HANDLE_VALUE;
1102 }
1103 return handle;
1104}
static IO_STATUS_BLOCK dummy_iosb
Definition: file.c:1062
NTSTATUS NTAPI NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, IN HANDLE EventHandle OPTIONAL, IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, IN PVOID ApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID Buffer, IN ULONG BufferSize, IN ULONG CompletionFilter, IN BOOLEAN WatchTree)
Definition: iofunc.c:1622
#define FILE_LIST_DIRECTORY
Definition: nt_native.h:629

Referenced by FindFirstChangeNotificationA().

◆ FindFirstFileA()

HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileA ( const char filename,
WIN32_FIND_DATAA data 
)

Definition at line 1363 of file file.c.

1364{
1366}
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExA(const char *filename, FINDEX_INFO_LEVELS level, void *data, FINDEX_SEARCH_OPS search_op, void *filter, DWORD flags)
Definition: file.c:1122
@ FindExSearchNameMatch
Definition: winbase.h:1175
@ FindExInfoStandard
Definition: winbase.h:1169

Referenced by test__lcreat(), test_filemodeT(), test_FindFirstFile_wildcards(), test_FindFirstFileA(), test_FindNextFileA(), and test_MoveFileA().

◆ FindFirstFileExA()

HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExA ( const char filename,
FINDEX_INFO_LEVELS  level,
void data,
FINDEX_SEARCH_OPS  search_op,
void filter,
DWORD  flags 
)

Definition at line 1122 of file file.c.

1125{
1126 HANDLE handle;
1127 WIN32_FIND_DATAA *dataA = data;
1128 WIN32_FIND_DATAW dataW;
1129 WCHAR *nameW;
1130
1132
1133 handle = FindFirstFileExW( nameW, level, &dataW, search_op, filter, flags );
1134 if (handle == INVALID_HANDLE_VALUE) return handle;
1135
1136 dataA->dwFileAttributes = dataW.dwFileAttributes;
1137 dataA->ftCreationTime = dataW.ftCreationTime;
1138 dataA->ftLastAccessTime = dataW.ftLastAccessTime;
1139 dataA->ftLastWriteTime = dataW.ftLastWriteTime;
1140 dataA->nFileSizeHigh = dataW.nFileSizeHigh;
1141 dataA->nFileSizeLow = dataW.nFileSizeLow;
1142 file_name_WtoA( dataW.cFileName, -1, dataA->cFileName, sizeof(dataA->cFileName) );
1143 file_name_WtoA( dataW.cAlternateFileName, -1, dataA->cAlternateFileName,
1144 sizeof(dataA->cAlternateFileName) );
1145 return handle;
1146}
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW(LPCWSTR filename, FINDEX_INFO_LEVELS level, LPVOID data, FINDEX_SEARCH_OPS search_op, LPVOID filter, DWORD flags)
Definition: file.c:1180
DWORD file_name_WtoA(LPCWSTR src, INT srclen, LPSTR dest, INT destlen)
Definition: file.c:438
GLint level
Definition: gl.h:1546

Referenced by FindFirstFileA().

◆ FindFirstFileExW()

HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileExW ( LPCWSTR  filename,
FINDEX_INFO_LEVELS  level,
LPVOID  data,
FINDEX_SEARCH_OPS  search_op,
LPVOID  filter,
DWORD  flags 
)

Definition at line 1180 of file file.c.

1183{
1184 WCHAR *mask;
1185 BOOL has_wildcard = FALSE;
1187 UNICODE_STRING nt_name;
1191 DWORD size, device = 0;
1192
1193 TRACE( "%s %d %p %d %p %lx\n", debugstr_w(filename), level, data, search_op, filter, flags );
1194
1196 {
1197 FIXME("flags not implemented 0x%08lx\n", flags );
1198 }
1199 if (search_op != FindExSearchNameMatch && search_op != FindExSearchLimitToDirectories)
1200 {
1201 FIXME( "search_op not implemented 0x%08x\n", search_op );
1203 return INVALID_HANDLE_VALUE;
1204 }
1206 {
1207 FIXME("info level %d not implemented\n", level );
1209 return INVALID_HANDLE_VALUE;
1210 }
1211
1212 if (!RtlDosPathNameToNtPathName_U( filename, &nt_name, &mask, NULL ))
1213 {
1215 return INVALID_HANDLE_VALUE;
1216 }
1217
1219 {
1220 WCHAR *dir = NULL;
1221
1222 /* we still need to check that the directory can be opened */
1223
1224 if (HIWORD(device))
1225 {
1226 if (!(dir = HeapAlloc( GetProcessHeap(), 0, HIWORD(device) + sizeof(WCHAR) )))
1227 {
1229 goto error;
1230 }
1232 dir[HIWORD(device)/sizeof(WCHAR)] = 0;
1233 }
1234 RtlFreeUnicodeString( &nt_name );
1235 if (!RtlDosPathNameToNtPathName_U( dir ? dir : L".", &nt_name, &mask, NULL ))
1236 {
1237 HeapFree( GetProcessHeap(), 0, dir );
1239 goto error;
1240 }
1241 HeapFree( GetProcessHeap(), 0, dir );
1242 size = 0;
1243 }
1244 else if (!mask || !*mask)
1245 {
1247 goto error;
1248 }
1249 else
1250 {
1251 nt_name.Length = (mask - nt_name.Buffer) * sizeof(WCHAR);
1252 has_wildcard = wcspbrk( mask, L"*?<>" ) != NULL;
1253 if (has_wildcard)
1254 {
1255 size = 8192;
1257 }
1258 else size = max_entry_size;
1259 }
1260
1262 {
1264 goto error;
1265 }
1266
1267 /* check if path is the root of the drive, skipping the \??\ prefix */
1268 info->is_root = FALSE;
1269 if (nt_name.Length >= 6 * sizeof(WCHAR) && nt_name.Buffer[5] == ':')
1270 {
1271 DWORD pos = 6;
1272 while (pos * sizeof(WCHAR) < nt_name.Length && nt_name.Buffer[pos] == '\\') pos++;
1273 info->is_root = (pos * sizeof(WCHAR) >= nt_name.Length);
1274 }
1275
1276 attr.Length = sizeof(attr);
1277 attr.RootDirectory = 0;
1278 attr.Attributes = OBJ_CASE_INSENSITIVE;
1279 attr.ObjectName = &nt_name;
1280 attr.SecurityDescriptor = NULL;
1281 attr.SecurityQualityOfService = NULL;
1282
1286 if (status != STATUS_SUCCESS)
1287 {
1290 else
1292 goto error;
1293 }
1294
1296 info->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FIND_FIRST_INFO.cs");
1297 info->path = nt_name;
1298 info->magic = FIND_FIRST_MAGIC;
1299 info->data_pos = 0;
1300 info->data_len = 0;
1301 info->data_size = size;
1302 info->search_op = search_op;
1303 info->level = level;
1304
1305 if (device)
1306 {
1307 WIN32_FIND_DATAW *wfd = data;
1308
1309 memset( wfd, 0, sizeof(*wfd) );
1310 memcpy( wfd->cFileName, filename + HIWORD(device)/sizeof(WCHAR), LOWORD(device) );
1311 wfd->dwFileAttributes = FILE_ATTRIBUTE_ARCHIVE;
1312 CloseHandle( info->handle );
1313 info->handle = 0;
1314 }
1315 else
1316 {
1317 WCHAR *fixedup_mask = mask;
1318 UNICODE_STRING mask_str;
1319
1320 if (has_wildcard && !(fixedup_mask = fixup_mask( mask ))) status = STATUS_NO_MEMORY;
1321 else
1322 {
1323 RtlInitUnicodeString( &mask_str, fixedup_mask );
1324 status = NtQueryDirectoryFile( info->handle, 0, NULL, NULL, &io, info->data, info->data_size,
1326 }
1327 if (fixedup_mask != mask) HeapFree( GetProcessHeap(), 0, fixedup_mask );
1328 if (status)
1329 {
1330 FindClose( info );
1332 return INVALID_HANDLE_VALUE;
1333 }
1334
1335 info->data_len = io.Information;
1336 if (!has_wildcard) info->data_size = 0; /* we read everything */
1337
1338 if (!FindNextFileW( info, data ))
1339 {
1340 TRACE( "%s not found\n", debugstr_w(filename) );
1341 FindClose( info );
1343 return INVALID_HANDLE_VALUE;
1344 }
1345 if (!has_wildcard) /* we can't find two files with the same name */
1346 {
1347 CloseHandle( info->handle );
1348 info->handle = 0;
1349 }
1350 }
1351 return info;
1352
1353error:
1354 HeapFree( GetProcessHeap(), 0, info );
1355 RtlFreeUnicodeString( &nt_name );
1356 return INVALID_HANDLE_VALUE;
1357}
unsigned int dir
Definition: maze.c:112
static WCHAR * fixup_mask(const WCHAR *mask)
Definition: file.c:1154
static const UINT max_entry_size
Definition: file.c:65
BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileW(HANDLE handle, WIN32_FIND_DATAW *data)
Definition: file.c:1422
BOOL WINAPI DECLSPEC_HOTPATCH FindClose(HANDLE handle)
Definition: file.c:1525
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
@ FileBothDirectoryInformation
Definition: from_kernel.h:64
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
GLenum GLint GLuint mask
Definition: glext.h:6028
NTSYSAPI NTSTATUS WINAPI RtlInitializeCriticalSectionEx(RTL_CRITICAL_SECTION *, ULONG, ULONG)
NTSTATUS NTAPI NtQueryDirectoryFile(IN HANDLE FileHandle, IN HANDLE EventHandle OPTIONAL, IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, IN PVOID ApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FileInformation, IN ULONG Length, IN FILE_INFORMATION_CLASS FileInformationClass, IN BOOLEAN ReturnSingleEntry, IN PUNICODE_STRING FileName OPTIONAL, IN BOOLEAN RestartScan)
Definition: iofunc.c:1994
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define LOWORD(l)
Definition: pedump.c:82
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
#define memset(x, y, z)
Definition: compat.h:39
Definition: devices.h:37
#define DWORD_PTR
Definition: treelist.c:76
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
@ FindExSearchLimitToDirectories
Definition: winbase.h:1176
#define FIND_FIRST_EX_LARGE_FETCH
Definition: winbase.h:268
@ FindExInfoBasic
Definition: winbase.h:1170
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1134

Referenced by FindFirstFileExA(), and FindFirstFileW().

◆ FindFirstFileNameW()

HANDLE WINAPI FindFirstFileNameW ( const WCHAR file_name,
DWORD  flags,
DWORD len,
WCHAR link_name 
)

Definition at line 1380 of file file.c.

1381{
1382 FIXME( "(%s, %lu, %p, %p): stub!\n", debugstr_w(file_name), flags, len, link_name );
1384 return INVALID_HANDLE_VALUE;
1385}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
static LPCWSTR file_name
Definition: protocol.c:147

◆ FindFirstFileW()

HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileW ( const WCHAR filename,
WIN32_FIND_DATAW data 
)

Definition at line 1372 of file file.c.

Referenced by GetLongPathNameW(), and GetShortPathNameW().

◆ FindFirstStreamW()

HANDLE WINAPI FindFirstStreamW ( const WCHAR filename,
STREAM_INFO_LEVELS  level,
void data,
DWORD  flags 
)

Definition at line 1390 of file file.c.

1391{
1392 FIXME("(%s, %d, %p, %lx): stub!\n", debugstr_w(filename), level, data, flags);
1394 return INVALID_HANDLE_VALUE;
1395}
#define ERROR_HANDLE_EOF
Definition: winerror.h:263

◆ FindNextChangeNotification()

BOOL WINAPI DECLSPEC_HOTPATCH FindNextChangeNotification ( HANDLE  handle)

Definition at line 1110 of file file.c.

1111{
1114 if (status == STATUS_PENDING) return TRUE;
1115 return set_ntstatus( status );
1116}
#define FILE_NOTIFY_CHANGE_SIZE

◆ FindNextFileA()

BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileA ( HANDLE  handle,
WIN32_FIND_DATAA data 
)

Definition at line 1401 of file file.c.

1402{
1403 WIN32_FIND_DATAW dataW;
1404
1405 if (!FindNextFileW( handle, &dataW )) return FALSE;
1406 data->dwFileAttributes = dataW.dwFileAttributes;
1407 data->ftCreationTime = dataW.ftCreationTime;
1408 data->ftLastAccessTime = dataW.ftLastAccessTime;
1409 data->ftLastWriteTime = dataW.ftLastWriteTime;
1410 data->nFileSizeHigh = dataW.nFileSizeHigh;
1411 data->nFileSizeLow = dataW.nFileSizeLow;
1412 file_name_WtoA( dataW.cFileName, -1, data->cFileName, sizeof(data->cFileName) );
1413 file_name_WtoA( dataW.cAlternateFileName, -1, data->cAlternateFileName,
1414 sizeof(data->cAlternateFileName) );
1415 return TRUE;
1416}

Referenced by test_FindFirstFile_wildcards(), test_FindFirstFileA(), test_FindFirstFileExA(), test_FindNextFileA(), and test_MoveFileA().

◆ FindNextFileW()

BOOL WINAPI DECLSPEC_HOTPATCH FindNextFileW ( HANDLE  handle,
WIN32_FIND_DATAW data 
)

Definition at line 1422 of file file.c.

1423{
1425 FILE_BOTH_DIR_INFORMATION *dir_info;
1426 BOOL ret = FALSE;
1428
1429 TRACE( "%p %p\n", handle, data );
1430
1431 if (!handle || handle == INVALID_HANDLE_VALUE || info->magic != FIND_FIRST_MAGIC)
1432 {
1434 return ret;
1435 }
1436
1438
1439 if (!info->handle) SetLastError( ERROR_NO_MORE_FILES );
1440 else for (;;)
1441 {
1442 if (info->data_pos >= info->data_len) /* need to read some more data */
1443 {
1445
1446 if (info->data_size)
1447 status = NtQueryDirectoryFile( info->handle, 0, NULL, NULL, &io, info->data, info->data_size,
1449 else
1451
1452 if (!set_ntstatus( status ))
1453 {
1455 {
1456 CloseHandle( info->handle );
1457 info->handle = 0;
1458 }
1459 break;
1460 }
1461 info->data_len = io.Information;
1462 info->data_pos = 0;
1463 }
1464
1465 dir_info = (FILE_BOTH_DIR_INFORMATION *)(info->data + info->data_pos);
1466
1467 if (dir_info->NextEntryOffset) info->data_pos += dir_info->NextEntryOffset;
1468 else info->data_pos = info->data_len;
1469
1470 /* don't return '.' and '..' in the root of the drive */
1471 if (info->is_root)
1472 {
1473 const WCHAR *file_name = dir_info->FileName;
1474 if (dir_info->FileNameLength == sizeof(WCHAR) && file_name[0] == '.') continue;
1475 if (dir_info->FileNameLength == 2 * sizeof(WCHAR) &&
1476 file_name[0] == '.' && file_name[1] == '.') continue;
1477 }
1478
1479 data->dwFileAttributes = dir_info->FileAttributes;
1480 data->ftCreationTime = *(FILETIME *)&dir_info->CreationTime;
1481 data->ftLastAccessTime = *(FILETIME *)&dir_info->LastAccessTime;
1482 data->ftLastWriteTime = *(FILETIME *)&dir_info->LastWriteTime;
1483 data->nFileSizeHigh = dir_info->EndOfFile.QuadPart >> 32;
1484 data->nFileSizeLow = (DWORD)dir_info->EndOfFile.QuadPart;
1485 data->dwReserved0 = 0;
1486 data->dwReserved1 = 0;
1487
1488 memcpy( data->cFileName, dir_info->FileName, dir_info->FileNameLength );
1489 data->cFileName[dir_info->FileNameLength/sizeof(WCHAR)] = 0;
1490
1491 if (info->level != FindExInfoBasic)
1492 {
1493 memcpy( data->cAlternateFileName, dir_info->ShortName, dir_info->ShortNameLength );
1494 data->cAlternateFileName[dir_info->ShortNameLength/sizeof(WCHAR)] = 0;
1495 }
1496 else
1497 data->cAlternateFileName[0] = 0;
1498
1499 TRACE( "returning %s (%s)\n",
1500 debugstr_w(data->cFileName), debugstr_w(data->cAlternateFileName) );
1501
1502 ret = TRUE;
1503 break;
1504 }
1505
1507 return ret;
1508}
LARGE_INTEGER CreationTime
Definition: from_kernel.h:141
LARGE_INTEGER LastAccessTime
Definition: from_kernel.h:142
LARGE_INTEGER LastWriteTime
Definition: from_kernel.h:143
#define STATUS_NO_MORE_FILES
Definition: udferr_usr.h:128
#define ERROR_NO_MORE_FILES
Definition: winerror.h:244

Referenced by FindFirstFileExW(), and FindNextFileA().

◆ FindNextStreamW()

BOOL WINAPI FindNextStreamW ( HANDLE  handle,
void data 
)

Definition at line 1514 of file file.c.

1515{
1516 FIXME( "(%p, %p): stub!\n", handle, data );
1518 return FALSE;
1519}

◆ fixup_mask()

static WCHAR * fixup_mask ( const WCHAR mask)
static

Definition at line 1154 of file file.c.

1155{
1156 unsigned int len = lstrlenW( mask ), i;
1157 BOOL no_ext;
1158 WCHAR *ret;
1159
1160 if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(*mask) ))) return NULL;
1161 memcpy( ret, mask, (len + 1) * sizeof(*mask) );
1162 if (!len) return ret;
1163 no_ext = ret[len - 1] == '.';
1164 while (len && (ret[len - 1] == '.' || ret[len - 1] == ' ')) --len;
1165
1166 for (i = 0; i < len; ++i)
1167 {
1168 if (ret[i] == '.' && (ret[i + 1] == '*' || ret[i + 1] == '?')) ret[i] = '\"';
1169 else if (ret[i] == '?') ret[i] = '>';
1170 }
1171 ret[len] = 0;
1172 if (no_ext && len && ret[len - 1] == '*') ret[len - 1] = '<';
1173 return ret;
1174}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by FindFirstFileExW(), and shader_glsl_color_correction_ext().

◆ FlushFileBuffers()

BOOL WINAPI DECLSPEC_HOTPATCH FlushFileBuffers ( HANDLE  file)

Definition at line 3027 of file file.c.

3028{
3030
3032}
NTSTATUS NTAPI NtFlushBuffersFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: iofunc.c:1487

Referenced by _commit().

◆ get_machine_wow64_dir()

static const WCHAR * get_machine_wow64_dir ( WORD  machine)
static

Definition at line 79 of file file.c.

80{
81 switch (machine)
82 {
83 case IMAGE_FILE_MACHINE_TARGET_HOST: return system_dir;
84 case IMAGE_FILE_MACHINE_I386: return L"C:\\windows\\syswow64";
85 case IMAGE_FILE_MACHINE_ARMNT: return L"C:\\windows\\sysarm32";
86 default: return NULL;
87 }
88}
#define IMAGE_FILE_MACHINE_ARMNT
Definition: compat.h:127
const WCHAR system_dir[]
Definition: file.c:68
static const char machine[]
Definition: profile.c:104
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174

Referenced by GetSystemWow64Directory2A(), GetSystemWow64Directory2W(), GetSystemWow64DirectoryA(), and GetSystemWow64DirectoryW().

◆ get_nt_file_options()

static UINT get_nt_file_options ( DWORD  attributes)
static

Definition at line 752 of file file.c.

753{
754 UINT options = 0;
755
756 if (attributes & FILE_FLAG_BACKUP_SEMANTICS)
758 else
760 if (attributes & FILE_FLAG_DELETE_ON_CLOSE)
762 if (attributes & FILE_FLAG_NO_BUFFERING)
764 if (!(attributes & FILE_FLAG_OVERLAPPED))
766 if (attributes & FILE_FLAG_RANDOM_ACCESS)
768 if (attributes & FILE_FLAG_SEQUENTIAL_SCAN)
770 if (attributes & FILE_FLAG_WRITE_THROUGH)
772 return options;
773}
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
#define FILE_RANDOM_ACCESS
Definition: from_kernel.h:38
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
#define FILE_SEQUENTIAL_ONLY
Definition: from_kernel.h:27

Referenced by CreateFileW(), and ReOpenFile().

◆ GetCommConfig()

BOOL WINAPI DECLSPEC_HOTPATCH GetCommConfig ( HANDLE  handle,
COMMCONFIG config,
DWORD size 
)

Definition at line 4311 of file file.c.

4312{
4313 if (!config) return FALSE;
4314
4315 TRACE( "(%p, %p, %p %lu)\n", handle, config, size, *size );
4316
4317 if (*size < sizeof(COMMCONFIG))
4318 {
4319 *size = sizeof(COMMCONFIG);
4320 return FALSE;
4321 }
4322 *size = sizeof(COMMCONFIG);
4323 config->dwSize = sizeof(COMMCONFIG);
4324 config->wVersion = 1;
4325 config->wReserved = 0;
4326 config->dwProviderSubType = PST_RS232;
4327 config->dwProviderOffset = 0;
4328 config->dwProviderSize = 0;
4329 return GetCommState( handle, &config->dcb );
4330}
BOOL WINAPI DECLSPEC_HOTPATCH GetCommState(HANDLE handle, DCB *dcb)
Definition: file.c:4365
#define PST_RS232
Definition: serial.h:17
struct _COMM_CONFIG COMMCONFIG

◆ GetCommMask()

BOOL WINAPI DECLSPEC_HOTPATCH GetCommMask ( HANDLE  handle,
DWORD mask 
)

Definition at line 4336 of file file.c.

4337{
4339 NULL, NULL );
4340}
#define IOCTL_SERIAL_GET_WAIT_MASK
Definition: ntddser.h:72

◆ GetCommModemStatus()

BOOL WINAPI DECLSPEC_HOTPATCH GetCommModemStatus ( HANDLE  handle,
DWORD status 
)

Definition at line 4346 of file file.c.

4347{
4349 NULL, NULL );
4350}
#define IOCTL_SERIAL_GET_MODEMSTATUS
Definition: ntddser.h:64

◆ GetCommProperties()

BOOL WINAPI DECLSPEC_HOTPATCH GetCommProperties ( HANDLE  handle,
COMMPROP prop 
)

Definition at line 4356 of file file.c.

4357{
4358 return DeviceIoControl( handle, IOCTL_SERIAL_GET_PROPERTIES, NULL, 0, prop, sizeof(*prop), NULL, NULL );
4359}
#define IOCTL_SERIAL_GET_PROPERTIES
Definition: ntddser.h:66

◆ GetCommState()

BOOL WINAPI DECLSPEC_HOTPATCH GetCommState ( HANDLE  handle,
DCB dcb 
)

Definition at line 4365 of file file.c.

4366{
4367 SERIAL_BAUD_RATE sbr;
4369 SERIAL_HANDFLOW shf;
4370 SERIAL_CHARS sc;
4371
4372 if (!dcb)
4373 {
4375 return FALSE;
4376 }
4377 if (!DeviceIoControl(handle, IOCTL_SERIAL_GET_BAUD_RATE, NULL, 0, &sbr, sizeof(sbr), NULL, NULL) ||
4378 !DeviceIoControl(handle, IOCTL_SERIAL_GET_LINE_CONTROL, NULL, 0, &slc, sizeof(slc), NULL, NULL) ||
4379 !DeviceIoControl(handle, IOCTL_SERIAL_GET_HANDFLOW, NULL, 0, &shf, sizeof(shf), NULL, NULL) ||
4380 !DeviceIoControl(handle, IOCTL_SERIAL_GET_CHARS, NULL, 0, &sc, sizeof(sc), NULL, NULL))
4381 return FALSE;
4382
4383 dcb->DCBlength = sizeof(*dcb);
4384 dcb->BaudRate = sbr.BaudRate;
4385 /* yes, they seem no never be (re)set on NT */
4386 dcb->fBinary = 1;
4387 dcb->fParity = 0;
4388 dcb->fOutxCtsFlow = !!(shf.ControlHandShake & SERIAL_CTS_HANDSHAKE);
4389 dcb->fOutxDsrFlow = !!(shf.ControlHandShake & SERIAL_DSR_HANDSHAKE);
4390 dcb->fDsrSensitivity = !!(shf.ControlHandShake & SERIAL_DSR_SENSITIVITY);
4391 dcb->fTXContinueOnXoff = !!(shf.FlowReplace & SERIAL_XOFF_CONTINUE);
4392 dcb->fOutX = !!(shf.FlowReplace & SERIAL_AUTO_TRANSMIT);
4393 dcb->fInX = !!(shf.FlowReplace & SERIAL_AUTO_RECEIVE);
4394 dcb->fErrorChar = !!(shf.FlowReplace & SERIAL_ERROR_CHAR);
4395 dcb->fNull = !!(shf.FlowReplace & SERIAL_NULL_STRIPPING);
4396 dcb->fAbortOnError = !!(shf.ControlHandShake & SERIAL_ERROR_ABORT);
4397 dcb->XonLim = shf.XonLimit;
4398 dcb->XoffLim = shf.XoffLimit;
4399 dcb->ByteSize = slc.WordLength;
4400 dcb->Parity = slc.Parity;
4401 dcb->StopBits = slc.StopBits;
4402 dcb->XonChar = sc.XonChar;
4403 dcb->XoffChar = sc.XoffChar;
4404 dcb->ErrorChar = sc.ErrorChar;
4405 dcb->EofChar = sc.EofChar;
4406 dcb->EvtChar = sc.EventChar;
4407
4409 {
4410 case SERIAL_DTR_CONTROL: dcb->fDtrControl = DTR_CONTROL_ENABLE; break;
4411 case SERIAL_DTR_HANDSHAKE: dcb->fDtrControl = DTR_CONTROL_HANDSHAKE; break;
4412 default: dcb->fDtrControl = DTR_CONTROL_DISABLE; break;
4413 }
4415 {
4416 case SERIAL_RTS_CONTROL: dcb->fRtsControl = RTS_CONTROL_ENABLE; break;
4417 case SERIAL_RTS_HANDSHAKE: dcb->fRtsControl = RTS_CONTROL_HANDSHAKE; break;
4419 dcb->fRtsControl = RTS_CONTROL_TOGGLE; break;
4420 default: dcb->fRtsControl = RTS_CONTROL_DISABLE; break;
4421 }
4422 dump_dcb( dcb );
4423 return TRUE;
4424}
static void dump_dcb(const DCB *dcb)
Definition: file.c:4186
#define SERIAL_DSR_SENSITIVITY
Definition: serial.c:128
#define SERIAL_ERROR_ABORT
Definition: serial.c:124
#define SERIAL_CTS_HANDSHAKE
Definition: serial.c:123
#define SERIAL_DTR_CONTROL
Definition: serial.c:122
#define SERIAL_RTS_HANDSHAKE
Definition: ntddser.h:203
#define SERIAL_ERROR_CHAR
Definition: ntddser.h:198
#define IOCTL_SERIAL_GET_CHARS
Definition: ntddser.h:52
#define SERIAL_DSR_HANDSHAKE
Definition: ntddser.h:190
#define SERIAL_DTR_HANDSHAKE
Definition: ntddser.h:188
#define IOCTL_SERIAL_GET_BAUD_RATE
Definition: ntddser.h:50
#define SERIAL_NULL_STRIPPING
Definition: ntddser.h:199
#define SERIAL_RTS_CONTROL
Definition: ntddser.h:202
#define SERIAL_AUTO_TRANSMIT
Definition: ntddser.h:196
#define SERIAL_AUTO_RECEIVE
Definition: ntddser.h:197
#define SERIAL_XOFF_CONTINUE
Definition: ntddser.h:205
#define IOCTL_SERIAL_GET_LINE_CONTROL
Definition: ntddser.h:60
#define IOCTL_SERIAL_GET_HANDFLOW
Definition: ntddser.h:58
UCHAR XoffChar
Definition: ntddser.h:167
UCHAR EventChar
Definition: ntddser.h:165
UCHAR ErrorChar
Definition: ntddser.h:163
UCHAR EofChar
Definition: ntddser.h:162
UCHAR XonChar
Definition: ntddser.h:166
ULONG ControlHandShake
Definition: ntddser.h:180
ULONG FlowReplace
Definition: ntddser.h:181
#define RTS_CONTROL_ENABLE
Definition: winbase.h:573
#define DTR_CONTROL_HANDSHAKE
Definition: winbase.h:571
#define DTR_CONTROL_DISABLE
Definition: winbase.h:569
#define RTS_CONTROL_TOGGLE
Definition: winbase.h:575
#define RTS_CONTROL_DISABLE
Definition: winbase.h:572
#define DTR_CONTROL_ENABLE
Definition: winbase.h:570

Referenced by GetCommConfig().

◆ GetCommTimeouts()

BOOL WINAPI DECLSPEC_HOTPATCH GetCommTimeouts ( HANDLE  handle,
COMMTIMEOUTS timeouts 
)

Definition at line 4430 of file file.c.

4431{
4432 if (!timeouts)
4433 {
4435 return FALSE;
4436 }
4438 NULL, NULL );
4439}
struct timeout * timeouts
Definition: dispatch.c:57
#define IOCTL_SERIAL_GET_TIMEOUTS
Definition: ntddser.h:70

◆ GetCompressedFileSizeA()

DWORD WINAPI DECLSPEC_HOTPATCH GetCompressedFileSizeA ( LPCSTR  name,
LPDWORD  size_high 
)

Definition at line 1570 of file file.c.

1571{
1572 WCHAR *nameW;
1573
1574 if (!(nameW = file_name_AtoW( name, FALSE ))) return INVALID_FILE_SIZE;
1575 return GetCompressedFileSizeW( nameW, size_high );
1576}
DWORD WINAPI DECLSPEC_HOTPATCH GetCompressedFileSizeW(LPCWSTR name, LPDWORD size_high)
Definition: file.c:1582
#define INVALID_FILE_SIZE
Definition: winbase.h:584

◆ GetCompressedFileSizeW()

DWORD WINAPI DECLSPEC_HOTPATCH GetCompressedFileSizeW ( LPCWSTR  name,
LPDWORD  size_high 
)

Definition at line 1582 of file file.c.

1583{
1584 UNICODE_STRING nt_name;
1588 HANDLE handle;
1589 DWORD ret;
1590
1591 TRACE("%s %p\n", debugstr_w(name), size_high);
1592
1593 if (!RtlDosPathNameToNtPathName_U( name, &nt_name, NULL, NULL ))
1594 {
1596 return INVALID_FILE_SIZE;
1597 }
1598
1599 attr.Length = sizeof(attr);
1600 attr.RootDirectory = 0;
1601 attr.Attributes = OBJ_CASE_INSENSITIVE;
1602 attr.ObjectName = &nt_name;
1603 attr.SecurityDescriptor = NULL;
1604 attr.SecurityQualityOfService = NULL;
1605
1607 RtlFreeUnicodeString( &nt_name );
1608 if (!set_ntstatus( status )) return INVALID_FILE_SIZE;
1609
1610 /* we don't support compressed files, simply return the file size */
1611 ret = GetFileSize( handle, size_high );
1612 NtClose( handle );
1613 return ret;
1614}
DWORD WINAPI DECLSPEC_HOTPATCH GetFileSize(HANDLE file, LPDWORD size_high)
Definition: file.c:3160

Referenced by GetCompressedFileSizeA().

◆ GetCurrentDirectoryA()

UINT WINAPI DECLSPEC_HOTPATCH GetCurrentDirectoryA ( UINT  buflen,
LPSTR  buf 
)

Definition at line 1620 of file file.c.

1621{
1622 WCHAR bufferW[MAX_PATH];
1623 DWORD ret;
1624
1625 if (buflen && buf && ((ULONG_PTR)buf >> 16) == 0)
1626 {
1627 /* Win9x catches access violations here, returning zero.
1628 * This behaviour resulted in some people not noticing
1629 * that they got the argument order wrong. So let's be
1630 * nice and fail gracefully if buf is invalid and looks
1631 * more like a buflen. */
1633 return 0;
1634 }
1635
1636 ret = RtlGetCurrentDirectory_U( sizeof(bufferW), bufferW );
1637 if (!ret) return 0;
1638 if (ret > sizeof(bufferW))
1639 {
1641 return 0;
1642 }
1643 return copy_filename_WtoA( bufferW, buf, buflen );
1644}
#define MAX_PATH
Definition: compat.h:34
static DWORD copy_filename_WtoA(LPCWSTR nameW, LPSTR buffer, DWORD len)
Definition: file.c:378
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
NTSYSAPI ULONG NTAPI RtlGetCurrentDirectory_U(_In_ ULONG MaximumLength, _Out_bytecap_(MaximumLength) PWSTR Buffer)
Definition: path.c:1661

Referenced by test_OpenFile().

◆ GetCurrentDirectoryW()

UINT WINAPI DECLSPEC_HOTPATCH GetCurrentDirectoryW ( UINT  buflen,
LPWSTR  buf 
)

Definition at line 1650 of file file.c.

1651{
1652 return RtlGetCurrentDirectory_U( buflen * sizeof(WCHAR), buf ) / sizeof(WCHAR);
1653}

◆ GetFileAttributesA()

DWORD WINAPI DECLSPEC_HOTPATCH GetFileAttributesA ( LPCSTR  name)

Definition at line 1659 of file file.c.

1660{
1661 WCHAR *nameW;
1662
1664 return GetFileAttributesW( nameW );
1665}
DWORD WINAPI DECLSPEC_HOTPATCH GetFileAttributesW(LPCWSTR name)
Definition: file.c:1671
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by _access(), _chmod(), _mktemp(), test__creat(), test__lcreat(), test_CopyFileEx(), test_file_disposition_information(), test_GetFileInformationByHandleEx(), test_OpenFile(), test_OpenFileById(), and tmpnam().

◆ GetFileAttributesExA()

BOOL WINAPI DECLSPEC_HOTPATCH GetFileAttributesExA ( LPCSTR  name,
GET_FILEEX_INFO_LEVELS  level,
void ptr 
)

Definition at line 1709 of file file.c.

1710{
1711 WCHAR *nameW;
1712
1713 if (!(nameW = file_name_AtoW( name, FALSE ))) return FALSE;
1714 return GetFileAttributesExW( nameW, level, ptr );
1715}
BOOL WINAPI DECLSPEC_HOTPATCH GetFileAttributesExW(LPCWSTR name, GET_FILEEX_INFO_LEVELS level, void *ptr)
Definition: file.c:1721
static PVOID ptr
Definition: dispmode.c:27

◆ GetFileAttributesExW()

BOOL WINAPI DECLSPEC_HOTPATCH GetFileAttributesExW ( LPCWSTR  name,
GET_FILEEX_INFO_LEVELS  level,
void ptr 
)

Definition at line 1721 of file file.c.

1722{
1725 UNICODE_STRING nt_name;
1728
1729 TRACE("%s %d %p\n", debugstr_w(name), level, ptr);
1730
1732 {
1734 return FALSE;
1735 }
1736
1737 if (!RtlDosPathNameToNtPathName_U( name, &nt_name, NULL, NULL ))
1738 {
1740 return FALSE;
1741 }
1742
1743 attr.Length = sizeof(attr);
1744 attr.RootDirectory = 0;
1745 attr.Attributes = OBJ_CASE_INSENSITIVE;
1746 attr.ObjectName = &nt_name;
1747 attr.SecurityDescriptor = NULL;
1748 attr.SecurityQualityOfService = NULL;
1749
1751 RtlFreeUnicodeString( &nt_name );
1752 if (!set_ntstatus( status )) return FALSE;
1753
1754 data->dwFileAttributes = info.FileAttributes;
1755 data->ftCreationTime.dwLowDateTime = info.CreationTime.u.LowPart;
1756 data->ftCreationTime.dwHighDateTime = info.CreationTime.u.HighPart;
1757 data->ftLastAccessTime.dwLowDateTime = info.LastAccessTime.u.LowPart;
1758 data->ftLastAccessTime.dwHighDateTime = info.LastAccessTime.u.HighPart;
1759 data->ftLastWriteTime.dwLowDateTime = info.LastWriteTime.u.LowPart;
1760 data->ftLastWriteTime.dwHighDateTime = info.LastWriteTime.u.HighPart;
1761 data->nFileSizeLow = info.EndOfFile.u.LowPart;
1762 data->nFileSizeHigh = info.EndOfFile.u.HighPart;
1763 return TRUE;
1764}
NTSTATUS NTAPI NtQueryFullAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation)
Definition: file.c:3991
@ GetFileExInfoStandard
Definition: winbase.h:1202

Referenced by GetFileAttributesExA(), and test_GetFileAttributesExW().

◆ GetFileAttributesW()

DWORD WINAPI DECLSPEC_HOTPATCH GetFileAttributesW ( LPCWSTR  name)

Definition at line 1671 of file file.c.

1672{
1674 UNICODE_STRING nt_name;
1677
1678 TRACE( "%s\n", debugstr_w(name) );
1679
1680 if (!RtlDosPathNameToNtPathName_U( name, &nt_name, NULL, NULL ))
1681 {
1684 }
1685
1686 attr.Length = sizeof(attr);
1687 attr.RootDirectory = 0;
1688 attr.Attributes = OBJ_CASE_INSENSITIVE;
1689 attr.ObjectName = &nt_name;
1690 attr.SecurityDescriptor = NULL;
1691 attr.SecurityQualityOfService = NULL;
1692
1694 RtlFreeUnicodeString( &nt_name );
1695
1696 if (status == STATUS_SUCCESS) return info.FileAttributes;
1697
1698 /* NtQueryAttributesFile fails on devices, but GetFileAttributesW succeeds */
1700
1703}
NTSTATUS NTAPI NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_BASIC_INFORMATION FileInformation)
Definition: file.c:3979

Referenced by _waccess(), _wchmod(), _wmktemp(), _wtmpnam(), GetFileAttributesA(), GetTempFileNameW(), test_file_link_information(), test_file_rename_information(), test_junction_points(), and test_NtCreateFile().

◆ GetFileInformationByHandle()

BOOL WINAPI DECLSPEC_HOTPATCH GetFileInformationByHandle ( HANDLE  file,
BY_HANDLE_FILE_INFORMATION info 
)

Definition at line 3038 of file file.c.

3039{
3041 FILE_STAT_INFORMATION stat_info;
3044
3045 status = NtQueryInformationFile( file, &io, &stat_info, sizeof(stat_info), FileStatInformation );
3046 if (!set_ntstatus( status )) return FALSE;
3047
3048 info->dwFileAttributes = stat_info.FileAttributes;
3049 info->ftCreationTime.dwHighDateTime = stat_info.CreationTime.u.HighPart;
3050 info->ftCreationTime.dwLowDateTime = stat_info.CreationTime.u.LowPart;
3051 info->ftLastAccessTime.dwHighDateTime = stat_info.LastAccessTime.u.HighPart;
3052 info->ftLastAccessTime.dwLowDateTime = stat_info.LastAccessTime.u.LowPart;
3053 info->ftLastWriteTime.dwHighDateTime = stat_info.LastWriteTime.u.HighPart;
3054 info->ftLastWriteTime.dwLowDateTime = stat_info.LastWriteTime.u.LowPart;
3055 info->dwVolumeSerialNumber = 0;
3056 info->nFileSizeHigh = stat_info.EndOfFile.u.HighPart;
3057 info->nFileSizeLow = stat_info.EndOfFile.u.LowPart;
3058 info->nNumberOfLinks = stat_info.NumberOfLinks;
3059 info->nFileIndexHigh = stat_info.FileId.u.HighPart;
3060 info->nFileIndexLow = stat_info.FileId.u.LowPart;
3061
3064 info->dwVolumeSerialNumber = volume_info.VolumeSerialNumber;
3065
3066 return TRUE;
3067}
#define FileStatInformation
Definition: fileinfo.c:28
@ FileFsVolumeInformation
Definition: from_kernel.h:219
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
LARGE_INTEGER LastAccessTime
Definition: fileinfo.c:42
LARGE_INTEGER FileId
Definition: fileinfo.c:40
LARGE_INTEGER EndOfFile
Definition: fileinfo.c:46
LARGE_INTEGER LastWriteTime
Definition: fileinfo.c:43
LARGE_INTEGER CreationTime
Definition: fileinfo.c:41
struct _LARGE_INTEGER::@2474 u

Referenced by test_CreateFileA(), and test_file_id_information().

◆ GetFileInformationByHandleEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetFileInformationByHandleEx ( HANDLE  handle,
FILE_INFO_BY_HANDLE_CLASS  class,
LPVOID  info,
DWORD  size 
)

Definition at line 3073 of file file.c.

3075{
3078
3079 switch (class)
3080 {
3081 case FileRemoteProtocolInfo:
3082 case FileStorageInfo:
3083 case FileDispositionInfoEx:
3084 case FileRenameInfoEx:
3085 case FileCaseSensitiveInfo:
3086 case FileNormalizedNameInfo:
3087 FIXME( "%p, %u, %p, %lu\n", handle, class, info, size );
3089 return FALSE;
3090
3091 case FileStreamInfo:
3093 break;
3094
3095 case FileCompressionInfo:
3097 break;
3098
3099 case FileAlignmentInfo:
3101 break;
3102
3103 case FileAttributeTagInfo:
3105 break;
3106
3107 case FileBasicInfo:
3109 break;
3110
3111 case FileStandardInfo:
3113 break;
3114
3115 case FileNameInfo:
3117 break;
3118
3119 case FileIdInfo:
3121 break;
3122
3123 case FileIdBothDirectoryRestartInfo:
3124 case FileIdBothDirectoryInfo:
3127 (class == FileIdBothDirectoryRestartInfo) );
3128 break;
3129
3130 case FileFullDirectoryInfo:
3131 case FileFullDirectoryRestartInfo:
3134 (class == FileFullDirectoryRestartInfo) );
3135 break;
3136
3137 case FileIdExtdDirectoryInfo:
3138 case FileIdExtdDirectoryRestartInfo:
3141 (class == FileIdExtdDirectoryRestartInfo) );
3142 break;
3143
3144 case FileRenameInfo:
3145 case FileDispositionInfo:
3146 case FileAllocationInfo:
3147 case FileIoPriorityHintInfo:
3148 case FileEndOfFileInfo:
3149 default:
3151 return FALSE;
3152 }
3153 return set_ntstatus( status );
3154}
#define FileIdExtdDirectoryInformation
Definition: dirctrl.c:24
#define FileIdInformation
Definition: fileinfo.c:24
@ FileCompressionInformation
Definition: from_kernel.h:89
@ FileAttributeTagInformation
Definition: from_kernel.h:96
@ FileAlignmentInformation
Definition: from_kernel.h:78
@ FileIdBothDirectoryInformation
Definition: from_kernel.h:98
@ FileNameInformation
Definition: from_kernel.h:70
@ FileFullDirectoryInformation
Definition: from_kernel.h:63
@ FileStreamInformation
Definition: from_kernel.h:83
#define FileStandardInformation
Definition: propsheet.cpp:61

◆ GetFileSize()

DWORD WINAPI DECLSPEC_HOTPATCH GetFileSize ( HANDLE  file,
LPDWORD  size_high 
)

Definition at line 3160 of file file.c.

3161{
3163
3164 if (!GetFileSizeEx( file, &size )) return INVALID_FILE_SIZE;
3165 if (size_high) *size_high = size.u.HighPart;
3166 if (size.u.LowPart == INVALID_FILE_SIZE) SetLastError( 0 );
3167 return size.u.LowPart;
3168}
#define GetFileSizeEx
Definition: compat.h:757

Referenced by GetCompressedFileSizeW(), test_CopyFile2(), test_CopyFileA(), and test_ReplaceFileA().

◆ GetFileSizeEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetFileSizeEx ( HANDLE  file,
PLARGE_INTEGER  size 
)

Definition at line 3174 of file file.c.

3175{
3178
3180 return FALSE;
3181
3182 *size = info.EndOfFile;
3183 return TRUE;
3184}

◆ GetFileTime()

BOOL WINAPI DECLSPEC_HOTPATCH GetFileTime ( HANDLE  file,
FILETIME creation,
FILETIME access,
FILETIME write 
)

Definition at line 3190 of file file.c.

3192{
3195
3197 return FALSE;
3198
3199 if (creation)
3200 {
3201 creation->dwHighDateTime = info.CreationTime.u.HighPart;
3202 creation->dwLowDateTime = info.CreationTime.u.LowPart;
3203 }
3204 if (access)
3205 {
3206 access->dwHighDateTime = info.LastAccessTime.u.HighPart;
3207 access->dwLowDateTime = info.LastAccessTime.u.LowPart;
3208 }
3209 if (write)
3210 {
3211 write->dwHighDateTime = info.LastWriteTime.u.HighPart;
3212 write->dwLowDateTime = info.LastWriteTime.u.LowPart;
3213 }
3214 return TRUE;
3215}
#define write
Definition: acwin.h:97
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by test_CopyFile2(), test_CopyFileA(), and test_ReplaceFileA().

◆ GetFileType()

DWORD WINAPI DECLSPEC_HOTPATCH GetFileType ( HANDLE  file)

Definition at line 3221 of file file.c.

3222{
3225
3226 if (file == (HANDLE)STD_INPUT_HANDLE ||
3230
3233 return FILE_TYPE_UNKNOWN;
3234
3235 switch (info.DeviceType)
3236 {
3237 case FILE_DEVICE_NULL:
3241 case FILE_DEVICE_TAPE:
3243 return FILE_TYPE_CHAR;
3245 return FILE_TYPE_PIPE;
3246 default:
3247 return FILE_TYPE_DISK;
3248 }
3249}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
@ FileFsDeviceInformation
Definition: from_kernel.h:222
#define FILE_DEVICE_SERIAL_PORT
Definition: serial.c:44
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:62
#define FILE_DEVICE_TAPE
Definition: winioctl.h:76
#define FILE_DEVICE_NULL
Definition: winioctl.h:66
#define FILE_DEVICE_UNKNOWN
Definition: winioctl.h:79
#define FILE_DEVICE_CONSOLE
Definition: winioctl.h:117
#define FILE_DEVICE_PARALLEL_PORT
Definition: winioctl.h:67
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define STD_OUTPUT_HANDLE
Definition: winbase.h:301
#define STD_INPUT_HANDLE
Definition: winbase.h:300
#define FILE_TYPE_UNKNOWN
Definition: winbase.h:291
#define STD_ERROR_HANDLE
Definition: winbase.h:302
#define FILE_TYPE_CHAR
Definition: winbase.h:293
#define FILE_TYPE_PIPE
Definition: winbase.h:294
#define FILE_TYPE_DISK
Definition: winbase.h:292

Referenced by _open_osfhandle(), _wsopen_s(), msvcrt_init_io(), and test_GetFileType().

◆ GetFinalPathNameByHandleA()

DWORD WINAPI DECLSPEC_HOTPATCH GetFinalPathNameByHandleA ( HANDLE  file,
LPSTR  path,
DWORD  count,
DWORD  flags 
)

Definition at line 1770 of file file.c.

1772{
1773 WCHAR *str;
1774 DWORD result, len;
1775
1776 TRACE( "(%p,%p,%ld,%lx)\n", file, path, count, flags);
1777
1779 if (len == 0) return 0;
1780
1781 str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1782 if (!str)
1783 {
1785 return 0;
1786 }
1787
1789 if (result != len - 1)
1790 {
1792 return 0;
1793 }
1794
1795 len = file_name_WtoA( str, -1, NULL, 0 );
1796 if (count < len)
1797 {
1799 return len - 1;
1800 }
1801 file_name_WtoA( str, -1, path, count );
1803 return len - 1;
1804}
DWORD WINAPI DECLSPEC_HOTPATCH GetFinalPathNameByHandleW(HANDLE file, LPWSTR path, DWORD count, DWORD flags)
Definition: file.c:1810
GLuint64EXT * result
Definition: glext.h:11304

◆ GetFinalPathNameByHandleW()

DWORD WINAPI DECLSPEC_HOTPATCH GetFinalPathNameByHandleW ( HANDLE  file,
LPWSTR  path,
DWORD  count,
DWORD  flags 
)

Definition at line 1810 of file file.c.

1812{
1815 WCHAR drive_part[MAX_PATH];
1816 DWORD drive_part_len = 0;
1818 DWORD result = 0;
1819 ULONG dummy;
1820 WCHAR *ptr;
1821
1822 TRACE( "(%p,%p,%ld,%lx)\n", file, path, count, flags );
1823
1825 {
1826 WARN("Unknown flags: %lx\n", flags);
1828 return 0;
1829 }
1830
1831 /* get object name */
1833 if (!set_ntstatus( status )) return 0;
1834
1835 if (!info->Name.Buffer)
1836 {
1838 return 0;
1839 }
1840 if (info->Name.Length < 4 * sizeof(WCHAR) || info->Name.Buffer[0] != '\\' ||
1841 info->Name.Buffer[1] != '?' || info->Name.Buffer[2] != '?' || info->Name.Buffer[3] != '\\' )
1842 {
1843 FIXME("Unexpected object name: %s\n", debugstr_wn(info->Name.Buffer, info->Name.Length / sizeof(WCHAR)));
1845 return 0;
1846 }
1847
1848 /* add terminating null character, remove "\\??\\" */
1849 info->Name.Buffer[info->Name.Length / sizeof(WCHAR)] = 0;
1850 info->Name.Length -= 4 * sizeof(WCHAR);
1851 info->Name.Buffer += 4;
1852
1853 /* FILE_NAME_OPENED is not supported yet, and would require Wineserver changes */
1854 if (flags & FILE_NAME_OPENED)
1855 {
1856 FIXME("FILE_NAME_OPENED not supported\n");
1857 flags &= ~FILE_NAME_OPENED;
1858 }
1859
1860 /* Get information required for VOLUME_NAME_NONE, VOLUME_NAME_GUID and VOLUME_NAME_NT */
1862 {
1863 if (!GetVolumePathNameW( info->Name.Buffer, drive_part, MAX_PATH )) return 0;
1864 drive_part_len = lstrlenW(drive_part);
1865 if (!drive_part_len || drive_part_len > lstrlenW(info->Name.Buffer) ||
1866 drive_part[drive_part_len-1] != '\\' ||
1867 CompareStringOrdinal( info->Name.Buffer, drive_part_len, drive_part, drive_part_len, TRUE ) != CSTR_EQUAL)
1868 {
1869 FIXME( "Path %s returned by GetVolumePathNameW does not match file path %s\n",
1870 debugstr_w(drive_part), debugstr_w(info->Name.Buffer) );
1872 return 0;
1873 }
1874 }
1875
1876 if (flags == VOLUME_NAME_NONE)
1877 {
1878 ptr = info->Name.Buffer + drive_part_len - 1;
1879 result = lstrlenW(ptr);
1880 if (result < count) memcpy(path, ptr, (result + 1) * sizeof(WCHAR));
1881 else result++;
1882 }
1883 else if (flags == VOLUME_NAME_GUID)
1884 {
1885 WCHAR volume_prefix[51];
1886
1887 /* GetVolumeNameForVolumeMountPointW sets error code on failure */
1888 if (!GetVolumeNameForVolumeMountPointW( drive_part, volume_prefix, 50 )) return 0;
1889 ptr = info->Name.Buffer + drive_part_len;
1890 result = lstrlenW(volume_prefix) + lstrlenW(ptr);
1891 if (result < count)
1892 {
1893 lstrcpyW(path, volume_prefix);
1894 lstrcatW(path, ptr);
1895 }
1896 else
1897 {
1899 result++;
1900 }
1901 }
1902 else if (flags == VOLUME_NAME_NT)
1903 {
1904 WCHAR nt_prefix[MAX_PATH];
1905
1906 /* QueryDosDeviceW sets error code on failure */
1907 drive_part[drive_part_len - 1] = 0;
1908 if (!QueryDosDeviceW( drive_part, nt_prefix, MAX_PATH )) return 0;
1909 ptr = info->Name.Buffer + drive_part_len - 1;
1910 result = lstrlenW(nt_prefix) + lstrlenW(ptr);
1911 if (result < count)
1912 {
1913 lstrcpyW(path, nt_prefix);
1914 lstrcatW(path, ptr);
1915 }
1916 else
1917 {
1919 result++;
1920 }
1921 }
1922 else if (flags == VOLUME_NAME_DOS)
1923 {
1924 result = 4 + lstrlenW(info->Name.Buffer);
1925 if (result < count)
1926 {
1927 lstrcpyW(path, L"\\\\?\\");
1928 lstrcatW(path, info->Name.Buffer);
1929 }
1930 else
1931 {
1933 result++;
1934 }
1935 }
1936 else
1937 {
1938 /* Windows crashes here, but we prefer returning ERROR_INVALID_PARAMETER */
1939 WARN("Invalid combination of flags: %lx\n", flags);
1941 }
1942 return result;
1943}
@ ObjectNameInformation
Definition: DriverTester.h:55
NTSTATUS NtQueryObject(IN HANDLE Handle, IN OBJECT_INFO_CLASS ObjectInformationClass, OUT PVOID ObjectInformation, IN ULONG ObjectInformationLength, OUT PULONG ReturnLength)
DWORD WINAPI QueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax)
Definition: dosdev.c:542
BOOL WINAPI GetVolumePathNameW(IN LPCWSTR lpszFileName, IN LPWSTR lpszVolumePathName, IN DWORD cchBufferLength)
Definition: volume.c:815
#define debugstr_wn
Definition: kernel32.h:33
BOOL WINAPI GetVolumeNameForVolumeMountPointW(IN LPCWSTR VolumeMountPoint, OUT LPWSTR VolumeName, IN DWORD VolumeNameLength)
Definition: mntpoint.c:496
#define FILE_NAME_OPENED
#define VOLUME_NAME_GUID
#define VOLUME_NAME_NONE
#define VOLUME_NAME_NT
#define VOLUME_NAME_DOS
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
#define ERROR_GEN_FAILURE
Definition: winerror.h:257

Referenced by GetFinalPathNameByHandleA().

◆ GetFullPathNameA()

DWORD WINAPI DECLSPEC_HOTPATCH GetFullPathNameA ( LPCSTR  name,
DWORD  len,
LPSTR  buffer,
LPSTR lastpart 
)

Definition at line 1949 of file file.c.

1950{
1951 WCHAR *nameW;
1952 WCHAR bufferW[MAX_PATH], *lastpartW = NULL;
1953 DWORD ret;
1954
1955 if (!(nameW = file_name_AtoW( name, FALSE ))) return 0;
1956
1957 ret = GetFullPathNameW( nameW, MAX_PATH, bufferW, &lastpartW );
1958
1959 if (!ret) return 0;
1960 if (ret > MAX_PATH)
1961 {
1963 return 0;
1964 }
1965 ret = copy_filename_WtoA( bufferW, buffer, len );
1966 if (ret < len && lastpart)
1967 {
1968 if (lastpartW)
1969 *lastpart = buffer + file_name_WtoA( bufferW, lastpartW - bufferW, NULL, 0 );
1970 else
1971 *lastpart = NULL;
1972 }
1973 return ret;
1974}
DWORD WINAPI DECLSPEC_HOTPATCH GetFullPathNameW(LPCWSTR name, DWORD len, LPWSTR buffer, LPWSTR *lastpart)
Definition: file.c:1980

◆ GetFullPathNameW()

DWORD WINAPI DECLSPEC_HOTPATCH GetFullPathNameW ( LPCWSTR  name,
DWORD  len,
LPWSTR  buffer,
LPWSTR lastpart 
)

Definition at line 1980 of file file.c.

1981{
1982 return RtlGetFullPathName_U( name, len * sizeof(WCHAR), buffer, lastpart ) / sizeof(WCHAR);
1983}
NTSYSAPI ULONG NTAPI RtlGetFullPathName_U(_In_ PCWSTR FileName, _In_ ULONG Size, _Out_z_bytecap_(Size) PWSTR Buffer, _Out_opt_ PWSTR *ShortName)
Definition: path.c:1987

Referenced by GetFullPathNameA(), GetTempPathW(), and SearchPathW().

◆ GetLocalTime()

void WINAPI DECLSPEC_HOTPATCH GetLocalTime ( SYSTEMTIME systime)

Definition at line 4052 of file file.c.

4053{
4054 LARGE_INTEGER ft, ft2;
4055
4056 NtQuerySystemTime( &ft );
4057 RtlSystemTimeToLocalTime( &ft, &ft2 );
4058 FileTimeToSystemTime( (FILETIME *)&ft2, systime );
4059}
BOOL WINAPI DECLSPEC_HOTPATCH FileTimeToSystemTime(const FILETIME *ft, SYSTEMTIME *systime)
Definition: file.c:4026
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:569

◆ GetLongPathNameA()

DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameA ( LPCSTR  shortpath,
LPSTR  longpath,
DWORD  longlen 
)

Definition at line 1989 of file file.c.

1990{
1991 WCHAR *shortpathW;
1992 WCHAR longpathW[MAX_PATH];
1993 DWORD ret;
1994
1995 TRACE( "%s\n", debugstr_a( shortpath ));
1996
1997 if (!(shortpathW = file_name_AtoW( shortpath, FALSE ))) return 0;
1998
1999 ret = GetLongPathNameW( shortpathW, longpathW, MAX_PATH );
2000
2001 if (!ret) return 0;
2002 if (ret > MAX_PATH)
2003 {
2005 return 0;
2006 }
2007 return copy_filename_WtoA( longpathW, longpath, longlen );
2008}
DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW(LPCWSTR shortpath, LPWSTR longpath, DWORD longlen)
Definition: file.c:2014
#define debugstr_a
Definition: kernel32.h:31
static char shortpath[MAX_PATH]
Definition: batch.c:32

Referenced by test_GetFinalPathNameByHandleA().

◆ GetLongPathNameW()

DWORD WINAPI DECLSPEC_HOTPATCH GetLongPathNameW ( LPCWSTR  shortpath,
LPWSTR  longpath,
DWORD  longlen 
)

Definition at line 2014 of file file.c.

2015{
2016 WCHAR tmplongpath[1024];
2017 DWORD sp = 0, lp = 0, tmplen;
2018 WIN32_FIND_DATAW wfd;
2020 LPCWSTR p;
2021 HANDLE handle;
2022
2023 TRACE("%s,%p,%lu\n", debugstr_w(shortpath), longpath, longlen);
2024
2025 if (!shortpath)
2026 {
2028 return 0;
2029 }
2030 if (!shortpath[0])
2031 {
2033 return 0;
2034 }
2035
2036 if (shortpath[0] == '\\' && shortpath[1] == '\\')
2037 {
2038 FIXME( "UNC pathname %s\n", debugstr_w(shortpath) );
2039 tmplen = lstrlenW( shortpath );
2040 if (tmplen < longlen)
2041 {
2042 if (longpath != shortpath) lstrcpyW( longpath, shortpath );
2043 return tmplen;
2044 }
2045 return tmplen + 1;
2046 }
2047
2048 /* check for drive letter */
2049 if (shortpath[0] != '/' && shortpath[1] == ':' )
2050 {
2051 tmplongpath[0] = shortpath[0];
2052 tmplongpath[1] = ':';
2053 lp = sp = 2;
2054 }
2055
2056 if (wcspbrk( shortpath + sp, L"*?" ))
2057 {
2059 return 0;
2060 }
2061
2062 while (shortpath[sp])
2063 {
2064 /* check for path delimiters and reproduce them */
2065 if (shortpath[sp] == '\\' || shortpath[sp] == '/')
2066 {
2067 tmplongpath[lp++] = shortpath[sp++];
2068 tmplongpath[lp] = 0; /* terminate string */
2069 continue;
2070 }
2071
2072 for (p = shortpath + sp; *p && *p != '/' && *p != '\\'; p++);
2073 tmplen = p - (shortpath + sp);
2074 lstrcpynW( tmplongpath + lp, shortpath + sp, tmplen + 1 );
2075
2076 if (tmplongpath[lp] == '.')
2077 {
2078 if (tmplen == 1 || (tmplen == 2 && tmplongpath[lp + 1] == '.'))
2079 {
2080 lp += tmplen;
2081 sp += tmplen;
2082 continue;
2083 }
2084 }
2085
2086 /* Check if the file exists */
2087 handle = FindFirstFileW( tmplongpath, &wfd );
2089 {
2090 TRACE( "not found %s\n", debugstr_w( tmplongpath ));
2092 return 0;
2093 }
2094 FindClose( handle );
2095
2096 /* Use the existing file name if it's a short name */
2097 RtlInitUnicodeString( &nameW, tmplongpath + lp );
2098 if (RtlIsNameLegalDOS8Dot3( &nameW, NULL, NULL )) lstrcpyW( tmplongpath + lp, wfd.cFileName );
2099 lp += lstrlenW( tmplongpath + lp );
2100 sp += tmplen;
2101 }
2102 tmplen = lstrlenW( shortpath ) - 1;
2103 if ((shortpath[tmplen] == '/' || shortpath[tmplen] == '\\') &&
2104 (tmplongpath[lp - 1] != '/' && tmplongpath[lp - 1] != '\\'))
2105 tmplongpath[lp++] = shortpath[tmplen];
2106 tmplongpath[lp] = 0;
2107
2108 tmplen = lstrlenW( tmplongpath ) + 1;
2109 if (tmplen <= longlen)
2110 {
2111 lstrcpyW( longpath, tmplongpath );
2112 TRACE("returning %s\n", debugstr_w( longpath ));
2113 tmplen--; /* length without 0 */
2114 }
2115 return tmplen;
2116}
#define ERROR_INVALID_NAME
Definition: compat.h:103
#define lstrcpynW
Definition: compat.h:738
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileW(const WCHAR *filename, WIN32_FIND_DATAW *data)
Definition: file.c:1372
BOOLEAN NTAPI RtlIsNameLegalDOS8Dot3(_In_ PUNICODE_STRING Name, _Inout_opt_ POEM_STRING OemName, _Inout_opt_ PBOOLEAN NameContainsSpaces)
static const WCHAR sp[]
Definition: suminfo.c:287

Referenced by GetLongPathNameA(), and test_GetFinalPathNameByHandleW().

◆ GetOverlappedResult()

BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResult ( HANDLE  file,
LPOVERLAPPED  overlapped,
LPDWORD  result,
BOOL  wait 
)

Definition at line 3255 of file file.c.

3257{
3258 return GetOverlappedResultEx( file, overlapped, result, wait ? INFINITE : 0, FALSE );
3259}
BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResultEx(HANDLE file, OVERLAPPED *overlapped, DWORD *result, DWORD timeout, BOOL alertable)
Definition: file.c:3265
#define INFINITE
Definition: serial.h:102

Referenced by test_async_file_errors(), test_file_completion_information(), test_overlapped(), and test_read_write().

◆ GetOverlappedResultEx()

BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResultEx ( HANDLE  file,
OVERLAPPED overlapped,
DWORD result,
DWORD  timeout,
BOOL  alertable 
)

Definition at line 3265 of file file.c.

3267{
3269 DWORD ret;
3270
3271 TRACE( "(%p %p %p %lu %d)\n", file, overlapped, result, timeout, alertable );
3272
3273 /* Paired with the write-release in set_async_iosb() in ntdll; see the
3274 * latter for details. */
3275 status = ReadAcquire( (LONG *)&overlapped->Internal );
3276 if (status == STATUS_PENDING)
3277 {
3278 if (!timeout)
3279 {
3281 return FALSE;
3282 }
3283 ret = WaitForSingleObjectEx( overlapped->hEvent ? overlapped->hEvent : file, timeout, alertable );
3284 if (ret == WAIT_FAILED)
3285 return FALSE;
3286 else if (ret)
3287 {
3288 SetLastError( ret );
3289 return FALSE;
3290 }
3291
3292 /* We don't need to give this load acquire semantics; the wait above
3293 * already guarantees that the IOSB and output buffer are filled. */
3294 status = overlapped->Internal;
3296 }
3297
3298 *result = overlapped->InternalHigh;
3299 return set_ntstatus( status );
3300}
long LONG
Definition: pedump.c:60
Definition: dhcpd.h:245
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define WAIT_FAILED
Definition: winbase.h:446
#define ERROR_IO_INCOMPLETE
Definition: winerror.h:901

Referenced by GetOverlappedResult().

◆ GetShortPathNameW()

DWORD WINAPI DECLSPEC_HOTPATCH GetShortPathNameW ( LPCWSTR  longpath,
LPWSTR  shortpath,
DWORD  shortlen 
)

Definition at line 2122 of file file.c.

2123{
2124 WIN32_FIND_DATAW wfd;
2125 WCHAR *tmpshortpath;
2126 HANDLE handle;
2127 LPCWSTR p;
2128 DWORD sp = 0, lp = 0, tmplen, buf_len;
2129
2130 TRACE( "%s,%p,%lu\n", debugstr_w(longpath), shortpath, shortlen );
2131
2132 if (!longpath)
2133 {
2135 return 0;
2136 }
2137 if (!longpath[0])
2138 {
2140 return 0;
2141 }
2142
2143 /* code below only removes characters from string, never adds, so this is
2144 * the largest buffer that tmpshortpath will need to have */
2145 buf_len = lstrlenW(longpath) + 1;
2146 tmpshortpath = HeapAlloc( GetProcessHeap(), 0, buf_len * sizeof(WCHAR) );
2147 if (!tmpshortpath)
2148 {
2150 return 0;
2151 }
2152
2153 if (longpath[0] == '\\' && longpath[1] == '\\' && longpath[2] == '?' && longpath[3] == '\\')
2154 {
2155 memcpy( tmpshortpath, longpath, 4 * sizeof(WCHAR) );
2156 sp = lp = 4;
2157 }
2158
2159 if (wcspbrk( longpath + lp, L"*?" ))
2160 {
2161 HeapFree( GetProcessHeap(), 0, tmpshortpath );
2163 return 0;
2164 }
2165
2166 /* check for drive letter */
2167 if (longpath[lp] != '/' && longpath[lp + 1] == ':' )
2168 {
2169 tmpshortpath[sp] = longpath[lp];
2170 tmpshortpath[sp + 1] = ':';
2171 sp += 2;
2172 lp += 2;
2173 }
2174
2175 while (longpath[lp])
2176 {
2177 /* check for path delimiters and reproduce them */
2178 if (longpath[lp] == '\\' || longpath[lp] == '/')
2179 {
2180 tmpshortpath[sp++] = longpath[lp++];
2181 tmpshortpath[sp] = 0; /* terminate string */
2182 continue;
2183 }
2184
2185 p = longpath + lp;
2186 for (; *p && *p != '/' && *p != '\\'; p++);
2187 tmplen = p - (longpath + lp);
2188 lstrcpynW( tmpshortpath + sp, longpath + lp, tmplen + 1 );
2189
2190 if (tmpshortpath[sp] == '.')
2191 {
2192 if (tmplen == 1 || (tmplen == 2 && tmpshortpath[sp + 1] == '.'))
2193 {
2194 sp += tmplen;
2195 lp += tmplen;
2196 continue;
2197 }
2198 }
2199
2200 /* Check if the file exists and use the existing short file name */
2201 handle = FindFirstFileW( tmpshortpath, &wfd );
2202 if (handle == INVALID_HANDLE_VALUE) goto notfound;
2203 FindClose( handle );
2204
2205 /* In rare cases (like "a.abcd") short path may be longer than original path.
2206 * Make sure we have enough space in temp buffer. */
2207 if (wfd.cAlternateFileName[0] && tmplen < lstrlenW(wfd.cAlternateFileName))
2208 {
2209 WCHAR *new_buf;
2210 buf_len += lstrlenW( wfd.cAlternateFileName ) - tmplen;
2211 new_buf = HeapReAlloc( GetProcessHeap(), 0, tmpshortpath, buf_len * sizeof(WCHAR) );
2212 if(!new_buf)
2213 {
2214 HeapFree( GetProcessHeap(), 0, tmpshortpath );
2216 return 0;
2217 }
2218 tmpshortpath = new_buf;
2219 }
2220
2221 lstrcpyW( tmpshortpath + sp, wfd.cAlternateFileName[0] ? wfd.cAlternateFileName : wfd.cFileName );
2222 sp += lstrlenW( tmpshortpath + sp );
2223 lp += tmplen;
2224 }
2225 tmpshortpath[sp] = 0;
2226
2227 tmplen = lstrlenW( tmpshortpath ) + 1;
2228 if (tmplen <= shortlen)
2229 {
2230 lstrcpyW( shortpath, tmpshortpath );
2231 TRACE( "returning %s\n", debugstr_w( shortpath ));
2232 tmplen--; /* length without 0 */
2233 }
2234
2235 HeapFree( GetProcessHeap(), 0, tmpshortpath );
2236 return tmplen;
2237
2238 notfound:
2239 HeapFree( GetProcessHeap(), 0, tmpshortpath );
2240 TRACE( "not found\n" );
2242 return 0;
2243}
#define HeapReAlloc
Definition: compat.h:734
#define ERROR_BAD_PATHNAME
Definition: winerror.h:356

◆ GetSystemDirectoryA()

UINT WINAPI DECLSPEC_HOTPATCH GetSystemDirectoryA ( LPSTR  path,
UINT  count 
)

Definition at line 2249 of file file.c.

2250{
2252}

◆ GetSystemDirectoryW()

UINT WINAPI DECLSPEC_HOTPATCH GetSystemDirectoryW ( LPWSTR  path,
UINT  count 
)

Definition at line 2258 of file file.c.

2259{
2260 return copy_filename( system_dir, path, count );
2261}
static DWORD copy_filename(const WCHAR *name, WCHAR *buffer, DWORD len)
Definition: file.c:361

Referenced by open_file_test(), test_file_all_name_information(), and test_file_name_information().

◆ GetSystemTime()

void WINAPI DECLSPEC_HOTPATCH GetSystemTime ( SYSTEMTIME systime)

Definition at line 4065 of file file.c.

4066{
4067 LARGE_INTEGER ft;
4068
4069 NtQuerySystemTime( &ft );
4070 FileTimeToSystemTime( (FILETIME *)&ft, systime );
4071}

◆ GetSystemTimeAdjustment()

BOOL WINAPI DECLSPEC_HOTPATCH GetSystemTimeAdjustment ( DWORD adjust,
DWORD increment,
BOOL disabled 
)

Definition at line 4077 of file file.c.

4078{
4080 ULONG len;
4081
4083 return FALSE;
4084 *adjust = st.TimeAdjustment;
4085 *increment = st.TimeIncrement;
4086 *disabled = st.TimeAdjustmentDisabled;
4087 return TRUE;
4088}
@ SystemTimeAdjustmentInformation
Definition: ntddk_ex.h:39
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)

◆ GetSystemTimeAsFileTime()

void WINAPI DECLSPEC_HOTPATCH GetSystemTimeAsFileTime ( FILETIME time)

Definition at line 4094 of file file.c.

4095{
4097}
__u16 time
Definition: mkdosfs.c:8

◆ GetSystemTimePreciseAsFileTime()

void WINAPI DECLSPEC_HOTPATCH GetSystemTimePreciseAsFileTime ( FILETIME time)

Definition at line 4103 of file file.c.

4104{
4106
4107 t.QuadPart = RtlGetSystemTimePrecise();
4108 time->dwLowDateTime = t.u.LowPart;
4109 time->dwHighDateTime = t.u.HighPart;
4110}
GLdouble GLdouble t
Definition: gl.h:2047
NTSYSAPI LONGLONG WINAPI RtlGetSystemTimePrecise(void)

◆ GetSystemWindowsDirectoryA()

UINT WINAPI DECLSPEC_HOTPATCH GetSystemWindowsDirectoryA ( LPSTR  path,
UINT  count 
)

Definition at line 2267 of file file.c.

2268{
2269 return GetWindowsDirectoryA( path, count );
2270}
UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryA(LPSTR path, UINT count)
Definition: file.c:2513

◆ GetSystemWindowsDirectoryW()

UINT WINAPI DECLSPEC_HOTPATCH GetSystemWindowsDirectoryW ( LPWSTR  path,
UINT  count 
)

Definition at line 2276 of file file.c.

2277{
2278 return GetWindowsDirectoryW( path, count );
2279}
UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryW(LPWSTR path, UINT count)
Definition: file.c:2522

◆ GetSystemWow64Directory2A()

UINT WINAPI DECLSPEC_HOTPATCH GetSystemWow64Directory2A ( LPSTR  path,
UINT  count,
WORD  machine 
)

Definition at line 2313 of file file.c.

2314{
2316
2317 return dir ? copy_filename_WtoA( dir, path, count ) : 0;
2318}
static const WCHAR * get_machine_wow64_dir(WORD machine)
Definition: file.c:79

◆ GetSystemWow64Directory2W()

UINT WINAPI DECLSPEC_HOTPATCH GetSystemWow64Directory2W ( LPWSTR  path,
UINT  count,
WORD  machine 
)

Definition at line 2324 of file file.c.

2325{
2327
2328 return dir ? copy_filename( dir, path, count ) : 0;
2329}

◆ GetSystemWow64DirectoryA()

UINT WINAPI GetSystemWow64DirectoryA ( LPSTR  path,
UINT  count 
)

Definition at line 2285 of file file.c.

2286{
2287 if (!is_win64 && !is_wow64)
2288 {
2290 return 0;
2291 }
2293}
BOOL is_wow64
Definition: main.c:38
static const BOOL is_win64
Definition: kernelbase.h:49

◆ GetSystemWow64DirectoryW()

UINT WINAPI GetSystemWow64DirectoryW ( LPWSTR  path,
UINT  count 
)

Definition at line 2299 of file file.c.

2300{
2301 if (!is_win64 && !is_wow64)
2302 {
2304 return 0;
2305 }
2307}

◆ GetTempFileNameA()

UINT WINAPI DECLSPEC_HOTPATCH GetTempFileNameA ( LPCSTR  path,
LPCSTR  prefix,
UINT  unique,
LPSTR  buffer 
)

◆ GetTempFileNameW()

UINT WINAPI DECLSPEC_HOTPATCH GetTempFileNameW ( LPCWSTR  path,
LPCWSTR  prefix,
UINT  unique,
LPWSTR  buffer 
)

Definition at line 2355 of file file.c.

2356{
2357 int i;
2358 LPWSTR p;
2359 DWORD attr;
2360
2361 if (!path || !buffer)
2362 {
2364 return 0;
2365 }
2366
2367 /* ensure that the provided directory exists */
2370 {
2371 TRACE( "path not found %s\n", debugstr_w( path ));
2373 return 0;
2374 }
2375
2376 lstrcpyW( buffer, path );
2377 p = buffer + lstrlenW(buffer);
2378
2379 /* add a \, if there isn't one */
2380 if ((p == buffer) || (p[-1] != '\\')) *p++ = '\\';
2381
2382 if (prefix) for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++;
2383
2384 unique &= 0xffff;
2385 if (unique) swprintf( p, MAX_PATH - (p - buffer), L"%x.tmp", unique );
2386 else
2387 {
2388 /* get a "random" unique number and try to create the file */
2389 HANDLE handle;
2390 UINT num = NtGetTickCount() & 0xffff;
2391 static UINT last;
2392
2393 /* avoid using the same name twice in a short interval */
2394 if (last - num < 10) num = last + 1;
2395 if (!num) num = 1;
2396 unique = num;
2397 do
2398 {
2399 swprintf( p, MAX_PATH - (p - buffer), L"%x.tmp", unique );
2402 { /* We created it */
2404 last = unique;
2405 break;
2406 }
2408 break; /* No need to go on */
2409 if (!(++unique & 0xffff)) unique = 1;
2410 } while (unique != num);
2411 }
2412 TRACE( "returning %s\n", debugstr_w( buffer ));
2413 return unique;
2414}
#define swprintf
Definition: precomp.h:40
GLuint GLuint num
Definition: glext.h:9618
static UINT UINT last
Definition: font.c:45
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define NtGetTickCount
Definition: rtlp.h:163
#define ERROR_DIRECTORY
Definition: winerror.h:417
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by _wtempnam(), GetTempFileNameA(), open_file_test(), processFile(), ReplaceFileW(), test_CopyFile2(), test_CopyFileW(), test_CreateFile2(), test_CreateFileW(), test_file_link_information(), test_file_rename_information(), test_GetFinalPathNameByHandleW(), test_junction_points(), test_MoveFileW(), test_NtCreateFile(), test_readonly(), and test_ReplaceFileW().

◆ GetTempPath2A()

DWORD WINAPI DECLSPEC_HOTPATCH GetTempPath2A ( DWORD  count,
LPSTR  path 
)

Definition at line 2491 of file file.c.

2492{
2493 /* TODO: Set temp path to C:\Windows\SystemTemp\ when a SYSTEM process calls this function */
2494 FIXME("(%lu, %p) semi-stub\n", count, path);
2495 return GetTempPathA(count, path);
2496}
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPathA(DWORD count, LPSTR path)
Definition: file.c:2420

◆ GetTempPath2W()

DWORD WINAPI DECLSPEC_HOTPATCH GetTempPath2W ( DWORD  count,
LPWSTR  path 
)

Definition at line 2502 of file file.c.

2503{
2504 /* TODO: Set temp path to C:\Windows\SystemTemp\ when a SYSTEM process calls this function */
2505 FIXME("(%lu, %p) semi-stub\n", count, path);
2506 return GetTempPathW(count, path);
2507}
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPathW(DWORD count, LPWSTR path)
Definition: file.c:2438

◆ GetTempPathA()

◆ GetTempPathW()

DWORD WINAPI DECLSPEC_HOTPATCH GetTempPathW ( DWORD  count,
LPWSTR  path 
)

Definition at line 2438 of file file.c.

2439{
2440 WCHAR tmp_path[MAX_PATH];
2441 UINT ret;
2442
2443 if (!(ret = GetEnvironmentVariableW( L"TMP", tmp_path, MAX_PATH )) &&
2444 !(ret = GetEnvironmentVariableW( L"TEMP", tmp_path, MAX_PATH )) &&
2445 !(ret = GetEnvironmentVariableW( L"USERPROFILE", tmp_path, MAX_PATH )) &&
2446 !(ret = GetWindowsDirectoryW( tmp_path, MAX_PATH )))
2447 return 0;
2448
2449 if (ret > MAX_PATH)
2450 {
2452 return 0;
2453 }
2454 ret = GetFullPathNameW( tmp_path, MAX_PATH, tmp_path, NULL );
2455 if (!ret) return 0;
2456
2457 if (ret > MAX_PATH - 2)
2458 {
2460 return 0;
2461 }
2462 if (tmp_path[ret-1] != '\\')
2463 {
2464 tmp_path[ret++] = '\\';
2465 tmp_path[ret] = '\0';
2466 }
2467
2468 ret++; /* add space for terminating 0 */
2469 if (count >= ret)
2470 {
2471 lstrcpynW( path, tmp_path, count );
2472 /* the remaining buffer must be zeroed up to 32766 bytes in XP or 32767
2473 * bytes after it, we will assume the > XP behavior for now */
2474 memset( path + ret, 0, (min(count, 32767) - ret) * sizeof(WCHAR) );
2475 ret--; /* return length without 0 */
2476 }
2477 else if (count)
2478 {
2479 /* the buffer must be cleared if contents will not fit */
2480 memset( path, 0, count * sizeof(WCHAR) );
2481 }
2482
2483 TRACE( "returning %u, %s\n", ret, debugstr_w( path ));
2484 return ret;
2485}
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755

Referenced by delete_file_test(), GetTempPath2W(), GetTempPathA(), open_file_test(), processFile(), test_CopyFile2(), test_CopyFileW(), test_CreateFile2(), test_CreateFileW(), test_DeleteFileW(), test_file_link_information(), test_file_rename_information(), test_GetFinalPathNameByHandleW(), test_MoveFileW(), test_NtCreateFile(), test_readonly(), and test_ReplaceFileW().

◆ GetWindowsDirectoryA()

UINT WINAPI DECLSPEC_HOTPATCH GetWindowsDirectoryA ( LPSTR  path,
UINT  count 
)

◆ GetWindowsDirectoryW()

◆ invoke_completion()

static void WINAPI invoke_completion ( void context,
IO_STATUS_BLOCK io,
ULONG  res 
)
static

Definition at line 3440 of file file.c.

3441{
3443 completion( RtlNtStatusToDosError( io->Status ), io->Information, (LPOVERLAPPED)io );
3444}
void CALLBACK completion(DWORD dwError, DWORD cbTransferred, LPWSAOVERLAPPED lpOverlapped, DWORD dwFlags)
Definition: WSARecv.c:16
Definition: http.c:7252
void(CALLBACK * LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD, DWORD, LPOVERLAPPED)
Definition: winbase.h:1492

Referenced by ReadDirectoryChangesW().

◆ is_same_file()

static BOOL is_same_file ( HANDLE  h1,
HANDLE  h2 
)
static

Definition at line 469 of file file.c.

470{
471 FILE_OBJECTID_BUFFER id1, id2;
473
474 return (!NtFsControlFile( h1, 0, NULL, NULL, &io, FSCTL_GET_OBJECT_ID, NULL, 0, &id1, sizeof(id1) ) &&
475 !NtFsControlFile( h2, 0, NULL, NULL, &io, FSCTL_GET_OBJECT_ID, NULL, 0, &id2, sizeof(id2) ) &&
476 !memcmp( &id1.ObjectId, &id2.ObjectId, sizeof(id1.ObjectId) ));
477}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define FSCTL_GET_OBJECT_ID
Definition: winioctl.h:130

Referenced by copy_file().

◆ kernelbase_Wow64EnableWow64FsRedirection()

DWORD WINAPI kernelbase_Wow64EnableWow64FsRedirection ( BOOLEAN  enable)

Definition at line 2971 of file file.c.

2972{
2974}
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirection(IN BOOLEAN Wow64FsEnableRedirection)
Definition: libsupp.c:1166
GLboolean enable
Definition: glext.h:11120

◆ LocalFileTimeToFileTime()

BOOL WINAPI DECLSPEC_HOTPATCH LocalFileTimeToFileTime ( const FILETIME local,
FILETIME utc 
)

Definition at line 4116 of file file.c.

4117{
4119}
NTSTATUS NTAPI RtlLocalTimeToSystemTime(IN PLARGE_INTEGER LocalTime, _Out_ PLARGE_INTEGER SystemTime)

◆ LockFile()

BOOL WINAPI DECLSPEC_HOTPATCH LockFile ( HANDLE  file,
DWORD  offset_low,
DWORD  offset_high,
DWORD  count_low,
DWORD  count_high 
)

Definition at line 3306 of file file.c.

3308{
3310
3311 TRACE( "%p %lx%08lx %lx%08lx\n", file, offset_high, offset_low, count_high, count_low );
3312
3313 count.u.LowPart = count_low;
3314 count.u.HighPart = count_high;
3315 offset.u.LowPart = offset_low;
3316 offset.u.HighPart = offset_high;
3317 return set_ntstatus( NtLockFile( file, 0, NULL, NULL, NULL, &offset, &count, NULL, TRUE, TRUE ));
3318}
GLintptr offset
Definition: glext.h:5920
NTSTATUS NTAPI NtLockFile(IN HANDLE FileHandle, IN HANDLE EventHandle OPTIONAL, IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, IN PVOID ApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER ByteOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN BOOLEAN FailImmediately, IN BOOLEAN ExclusiveLock)
Definition: iofunc.c:1764

Referenced by _locking(), and test_LockFile().

◆ LockFileEx()

BOOL WINAPI DECLSPEC_HOTPATCH LockFileEx ( HANDLE  file,
DWORD  flags,
DWORD  reserved,
DWORD  count_low,
DWORD  count_high,
LPOVERLAPPED  overlapped 
)

Definition at line 3324 of file file.c.

3326{
3328 LPVOID cvalue = NULL;
3329
3330 if (reserved)
3331 {
3333 return FALSE;
3334 }
3335
3336 TRACE( "%p %lx%08lx %lx%08lx flags %lx\n",
3337 file, overlapped->OffsetHigh, overlapped->Offset, count_high, count_low, flags );
3338
3339 count.u.LowPart = count_low;
3340 count.u.HighPart = count_high;
3341 offset.u.LowPart = overlapped->Offset;
3342 offset.u.HighPart = overlapped->OffsetHigh;
3343
3344 if (((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
3345
3346 return set_ntstatus( NtLockFile( file, overlapped->hEvent, NULL, cvalue,
3347 NULL, &offset, &count, NULL,
3350}
r reserved
Definition: btrfs.c:3006
#define LOCKFILE_FAIL_IMMEDIATELY
Definition: winbase.h:418
#define LOCKFILE_EXCLUSIVE_LOCK
Definition: winbase.h:419

Referenced by test_LockFile().

◆ MoveFileExW()

BOOL WINAPI MoveFileExW ( const WCHAR source,
const WCHAR dest,
DWORD  flag 
)

Definition at line 2531 of file file.c.

2532{
2534}
BOOL WINAPI DECLSPEC_HOTPATCH MoveFileWithProgressW(const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUTINE progress, void *param, DWORD flag)
Definition: file.c:2540
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52

Referenced by _wrename(), and ReplaceFileW().

◆ MoveFileWithProgressW()

BOOL WINAPI DECLSPEC_HOTPATCH MoveFileWithProgressW ( const WCHAR source,
const WCHAR dest,
LPPROGRESS_ROUTINE  progress,
void param,
DWORD  flag 
)

Definition at line 2540 of file file.c.

2543{
2544 FILE_RENAME_INFORMATION *rename_info;
2546 UNICODE_STRING nt_name;
2550 HANDLE source_handle = 0;
2551 ULONG size;
2552
2553 TRACE( "(%s,%s,%p,%p,%04lx)\n", debugstr_w(source), debugstr_w(dest), progress, param, flag );
2554
2556
2557 if (!dest) return DeleteFileW( source );
2558
2559 /* check if we are allowed to rename the source */
2560
2561 if (!RtlDosPathNameToNtPathName_U( source, &nt_name, NULL, NULL ))
2562 {
2564 return FALSE;
2565 }
2566 attr.Length = sizeof(attr);
2567 attr.RootDirectory = 0;
2568 attr.Attributes = OBJ_CASE_INSENSITIVE;
2569 attr.ObjectName = &nt_name;
2570 attr.SecurityDescriptor = NULL;
2571 attr.SecurityQualityOfService = NULL;
2572
2573 status = NtOpenFile( &source_handle, DELETE | SYNCHRONIZE, &attr, &io,
2576 RtlFreeUnicodeString( &nt_name );
2577 if (!set_ntstatus( status )) goto error;
2578
2579 status = NtQueryInformationFile( source_handle, &io, &info, sizeof(info), FileBasicInformation );
2580 if (!set_ntstatus( status )) goto error;
2581
2582 if (!RtlDosPathNameToNtPathName_U( dest, &nt_name, NULL, NULL ))
2583 {
2585 goto error;
2586 }
2587
2589 if (!(rename_info = HeapAlloc( GetProcessHeap(), 0, size ))) goto error;
2590
2591 rename_info->ReplaceIfExists = !!(flag & MOVEFILE_REPLACE_EXISTING);
2592 rename_info->RootDirectory = NULL;
2593 rename_info->FileNameLength = nt_name.Length;
2594 memcpy( rename_info->FileName, nt_name.Buffer, nt_name.Length );
2595 RtlFreeUnicodeString( &nt_name );
2596 status = NtSetInformationFile( source_handle, &io, rename_info, size, FileRenameInformation );
2597 HeapFree( GetProcessHeap(), 0, rename_info );
2599 {
2600 NtClose( source_handle );
2603 return FALSE;
2604 return DeleteFileW( source );
2605 }
2606
2607 NtClose( source_handle );
2608 return set_ntstatus( status );
2609
2610error:
2611 if (source_handle) NtClose( source_handle );
2612 return FALSE;
2613}
static BOOL add_boot_rename_entry(LPCWSTR source, LPCWSTR dest, DWORD flags)
Definition: file.c:142
#define MOVEFILE_COPY_ALLOWED
Definition: filesup.h:29
@ FileRenameInformation
Definition: from_kernel.h:71
GLfloat param
Definition: glext.h:5796
#define STATUS_NOT_SAME_DEVICE
Definition: ntstatus.h:448
#define MOVEFILE_DELAY_UNTIL_REBOOT
Definition: winbase.h:433

Referenced by MoveFileExW().

◆ NeedCurrentDirectoryForExePathA()

BOOL WINAPI DECLSPEC_HOTPATCH NeedCurrentDirectoryForExePathA ( LPCSTR  name)

Definition at line 2619 of file file.c.

2620{
2621 WCHAR *nameW;
2622
2623 if (!(nameW = file_name_AtoW( name, FALSE ))) return TRUE;
2625}
BOOL WINAPI DECLSPEC_HOTPATCH NeedCurrentDirectoryForExePathW(LPCWSTR name)
Definition: file.c:2631

◆ NeedCurrentDirectoryForExePathW()

BOOL WINAPI DECLSPEC_HOTPATCH NeedCurrentDirectoryForExePathW ( LPCWSTR  name)

Definition at line 2631 of file file.c.

2632{
2633 WCHAR env_val;
2634
2635 if (wcschr( name, '\\' )) return TRUE;
2636 /* check the existence of the variable, not value */
2637 return !GetEnvironmentVariableW( L"NoDefaultCurrentDirectoryInExePath", &env_val, 1 );
2638}

Referenced by NeedCurrentDirectoryForExePathA().

◆ OpenFileById()

HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileById ( HANDLE  handle,
LPFILE_ID_DESCRIPTOR  id,
DWORD  access,
DWORD  share,
LPSECURITY_ATTRIBUTES  sec_attr,
DWORD  flags 
)

Definition at line 3356 of file file.c.

3358{
3359 UINT options;
3360 HANDLE result;
3363 UNICODE_STRING objectName;
3364
3365 if (!id)
3366 {
3368 return INVALID_HANDLE_VALUE;
3369 }
3370
3374 else
3381
3382 objectName.Length = sizeof(ULONGLONG);
3383 objectName.Buffer = (WCHAR *)&id->FileId;
3384 attr.Length = sizeof(attr);
3385 attr.RootDirectory = handle;
3386 attr.Attributes = 0;
3387 attr.ObjectName = &objectName;
3388 attr.SecurityDescriptor = sec_attr ? sec_attr->lpSecurityDescriptor : NULL;
3389 attr.SecurityQualityOfService = NULL;
3390 if (sec_attr && sec_attr->bInheritHandle) attr.Attributes |= OBJ_INHERIT;
3391
3393 share, OPEN_EXISTING, options, NULL, 0 )))
3394 return INVALID_HANDLE_VALUE;
3395 return result;
3396}
#define FILE_OPEN_BY_FILE_ID
Definition: from_kernel.h:41
GLuint id
Definition: glext.h:5910
LPVOID lpSecurityDescriptor
Definition: compat.h:193
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ PurgeComm()

BOOL WINAPI DECLSPEC_HOTPATCH PurgeComm ( HANDLE  handle,
DWORD  flags 
)

Definition at line 4444 of file file.c.

4445{
4447 NULL, 0, NULL, NULL );
4448}
#define IOCTL_SERIAL_PURGE
Definition: ntddser.h:78

◆ QueryIoRingCapabilities()

HRESULT WINAPI QueryIoRingCapabilities ( IORING_CAPABILITIES *  caps)

Definition at line 4600 of file file.c.

4601{
4602 FIXME( "caps %p stub.\n", caps );
4603
4604 return E_NOTIMPL;
4605}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ read_write_apc()

static void WINAPI read_write_apc ( void apc_user,
PIO_STATUS_BLOCK  io,
ULONG  reserved 
)
static

Definition at line 73 of file file.c.

74{
76 func( RtlNtStatusToDosError( io->Status ), io->Information, (LPOVERLAPPED)io );
77}
static HANDLE PIO_APC_ROUTINE void * apc_user
Definition: comm.c:55

Referenced by ReadFileEx(), and WriteFileEx().

◆ ReadDirectoryChangesW()

BOOL WINAPI DECLSPEC_HOTPATCH ReadDirectoryChangesW ( HANDLE  handle,
LPVOID  buffer,
DWORD  len,
BOOL  subtree,
DWORD  filter,
LPDWORD  returned,
LPOVERLAPPED  overlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  completion 
)

Definition at line 3449 of file file.c.

3453{
3454 OVERLAPPED ov, *pov;
3457 LPVOID cvalue = NULL;
3458
3459 TRACE( "%p %p %08lx %d %08lx %p %p %p\n",
3460 handle, buffer, len, subtree, filter, returned, overlapped, completion );
3461
3462 if (!overlapped)
3463 {
3464 memset( &ov, 0, sizeof ov );
3465 ov.hEvent = CreateEventW( NULL, 0, 0, NULL );
3466 pov = &ov;
3467 }
3468 else
3469 {
3470 pov = overlapped;
3471 if (completion) cvalue = completion;
3472 else if (((ULONG_PTR)overlapped->hEvent & 1) == 0) cvalue = overlapped;
3473 }
3474
3475 ios = (PIO_STATUS_BLOCK)pov;
3476 ios->Status = STATUS_PENDING;
3477
3480 cvalue, ios, buffer, len, filter, subtree );
3481 if (status == STATUS_PENDING)
3482 {
3483 if (overlapped) return TRUE;
3485 if (returned) *returned = ios->Information;
3486 status = ios->Status;
3487 }
3488 if (!overlapped) CloseHandle( ov.hEvent );
3489 return set_ntstatus( status );
3490}
basic_ios< char, char_traits< char > > ios
Definition: _iosfwd.h:78
static void WINAPI invoke_completion(void *context, IO_STATUS_BLOCK *io, ULONG res)
Definition: file.c:3440
struct _IO_STATUS_BLOCK * PIO_STATUS_BLOCK
Definition: change.c:34
HANDLE hEvent
Definition: winbase.h:855
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651

◆ ReadFile()

BOOL WINAPI DECLSPEC_HOTPATCH ReadFile ( HANDLE  file,
LPVOID  buffer,
DWORD  count,
LPDWORD  result,
LPOVERLAPPED  overlapped 
)

Definition at line 3496 of file file.c.

3498{
3500 PLARGE_INTEGER poffset = NULL;
3503 HANDLE event = 0;
3505 LPVOID cvalue = NULL;
3506
3507 TRACE( "%p %p %ld %p %p\n", file, buffer, count, result, overlapped );
3508
3509 if (result) *result = 0;
3510
3511 if (overlapped)
3512 {
3513 offset.u.LowPart = overlapped->Offset;
3514 offset.u.HighPart = overlapped->OffsetHigh;
3515 poffset = &offset;
3516 event = overlapped->hEvent;
3518 if (((ULONG_PTR)event & 1) == 0) cvalue = overlapped;
3519 }
3520 else io_status->Information = 0;
3521 io_status->Status = STATUS_PENDING;
3522
3523 status = NtReadFile( file, event, NULL, cvalue, io_status, buffer, count, poffset, NULL);
3524
3525 if (status == STATUS_PENDING && !overlapped)
3526 {
3528 status = io_status->Status;
3529 }
3530
3531 if (result) *result = overlapped && status ? 0 : io_status->Information;
3532
3534 {
3535 if (overlapped != NULL)
3536 {
3538 return FALSE;
3539 }
3540 }
3541 else if (status && status != STATUS_TIMEOUT)
3542 {
3544 return FALSE;
3545 }
3546 return TRUE;
3547}
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:56
#define STATUS_END_OF_FILE
Definition: shellext.h:67
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

◆ ReadFileEx()

BOOL WINAPI DECLSPEC_HOTPATCH ReadFileEx ( HANDLE  file,
LPVOID  buffer,
DWORD  count,
LPOVERLAPPED  overlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  completion 
)

Definition at line 3553 of file file.c.

3555{
3559
3560 TRACE( "(file=%p, buffer=%p, bytes=%lu, ovl=%p, ovl_fn=%p)\n",
3562
3563 if (!overlapped)
3564 {
3566 return FALSE;
3567 }
3568 offset.u.LowPart = overlapped->Offset;
3569 offset.u.HighPart = overlapped->OffsetHigh;
3571 io->Status = STATUS_PENDING;
3572 io->Information = 0;
3573
3575 if (status == STATUS_PENDING) return TRUE;
3576 return set_ntstatus( status );
3577}
static void WINAPI read_write_apc(void *apc_user, PIO_STATUS_BLOCK io, ULONG reserved)
Definition: file.c:73

Referenced by test_async_file_errors().

◆ ReadFileScatter()

BOOL WINAPI DECLSPEC_HOTPATCH ReadFileScatter ( HANDLE  file,
FILE_SEGMENT_ELEMENT segments,
DWORD  count,
LPDWORD  reserved,
LPOVERLAPPED  overlapped 
)

Definition at line 3583 of file file.c.

3585{
3588 void *cvalue = NULL;
3589
3590 TRACE( "(%p %p %lu %p)\n", file, segments, count, overlapped );
3591
3592 offset.u.LowPart = overlapped->Offset;
3593 offset.u.HighPart = overlapped->OffsetHigh;
3594 if (!((ULONG_PTR)overlapped->hEvent & 1)) cvalue = overlapped;
3596 io->Status = STATUS_PENDING;
3597 io->Information = 0;
3598
3599 return set_ntstatus( NtReadFileScatter( file, overlapped->hEvent, NULL, cvalue, io,
3600 segments, count, &offset, NULL ));
3601}
NTSTATUS NTAPI NtReadFileScatter(IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, IN PVOID UserApcContext OPTIONAL, OUT PIO_STATUS_BLOCK UserIoStatusBlock, IN FILE_SEGMENT_ELEMENT BufferDescription[], IN ULONG BufferLength, IN PLARGE_INTEGER ByteOffset, IN PULONG Key OPTIONAL)
Definition: iofunc.c:3063

Referenced by test_WriteFileGather().

◆ RemoveDirectoryA()

BOOL WINAPI DECLSPEC_HOTPATCH RemoveDirectoryA ( LPCSTR  path)

Definition at line 3607 of file file.c.

3608{
3609 WCHAR *pathW;
3610
3611 if (!(pathW = file_name_AtoW( path, FALSE ))) return FALSE;
3612 return RemoveDirectoryW( pathW );
3613}
BOOL WINAPI DECLSPEC_HOTPATCH RemoveDirectoryW(LPCWSTR path)
Definition: file.c:3619

Referenced by test_CreateFileA(), test_DeleteFileA(), test_file_disposition_information(), test_FindFirstFile_wildcards(), test_FindFirstFileA(), test_FindFirstFileExA(), test_MoveFileA(), and test_RemoveDirectory().

◆ RemoveDirectoryW()

BOOL WINAPI DECLSPEC_HOTPATCH RemoveDirectoryW ( LPCWSTR  path)

Definition at line 3619 of file file.c.

3620{
3622 UNICODE_STRING nt_name;
3625 HANDLE handle;
3626
3627 TRACE( "%s\n", debugstr_w(path) );
3628
3630 if (!set_ntstatus( status )) return FALSE;
3631
3636 RtlFreeUnicodeString( &nt_name );
3637
3638 if (!status)
3639 {
3642 NtClose( handle );
3643 }
3644 return set_ntstatus( status );
3645}
@ FileDispositionInformation
Definition: from_kernel.h:74
NTSYSAPI NTSTATUS WINAPI RtlDosPathNameToNtPathName_U_WithStatus(PCWSTR, PUNICODE_STRING, PWSTR *, CURDIR *)

Referenced by delete_file_test(), delete_object(), RemoveDirectoryA(), test_CreateFile2(), test_CreateFileW(), test_DeleteFileW(), and test_junction_points().

◆ ReOpenFile()

HANDLE WINAPI DECLSPEC_HOTPATCH ReOpenFile ( HANDLE  handle,
DWORD  access,
DWORD  sharing,
DWORD  attributes 
)

Definition at line 3402 of file file.c.

3403{
3406 UNICODE_STRING empty = { 0 };
3409 HANDLE file;
3410
3411 TRACE("handle %p, access %#lx, sharing %#lx, attributes %#lx.\n", handle, access, sharing, attributes);
3412
3413 if (attributes & 0x7ffff) /* FILE_ATTRIBUTE_* flags are invalid */
3414 {
3416 return INVALID_HANDLE_VALUE;
3417 }
3418
3419 if (attributes & FILE_FLAG_DELETE_ON_CLOSE)
3420 access |= DELETE;
3421
3423 if (attributes & SECURITY_SQOS_PRESENT)
3424 {
3425 qos.Length = sizeof(qos);
3426 qos.ImpersonationLevel = (attributes >> 16) & 0x3;
3428 qos.EffectiveOnly = (attributes & SECURITY_EFFECTIVE_ONLY) != 0;
3429 attr.SecurityQualityOfService = &qos;
3430 }
3431
3433 0, sharing, FILE_OPEN, get_nt_file_options( attributes ), NULL, 0 );
3434 if (!set_ntstatus( status ))
3435 return INVALID_HANDLE_VALUE;
3436 return file;
3437}
static const WCHAR empty[]
Definition: main.c:47

◆ ReplaceFileW()

BOOL WINAPI DECLSPEC_HOTPATCH ReplaceFileW ( const WCHAR replaced,
const WCHAR replacement,
const WCHAR backup,
DWORD  flags,
void exclude,
void reserved 
)

Definition at line 2644 of file file.c.

2647{
2648 UNICODE_STRING nt_replaced_name, nt_replacement_name;
2649 HANDLE hReplacement = NULL;
2654
2655 TRACE( "%s %s %s 0x%08lx %p %p\n", debugstr_w(replaced), debugstr_w(replacement), debugstr_w(backup),
2656 flags, exclude, reserved );
2657
2658 if (flags) FIXME("Ignoring flags %lx\n", flags);
2659
2660 /* First two arguments are mandatory */
2661 if (!replaced || !replacement)
2662 {
2664 return FALSE;
2665 }
2666
2667 attr.Length = sizeof(attr);
2668 attr.RootDirectory = 0;
2669 attr.Attributes = OBJ_CASE_INSENSITIVE;
2670 attr.ObjectName = NULL;
2671 attr.SecurityDescriptor = NULL;
2672 attr.SecurityQualityOfService = NULL;
2673
2674 /* Open the "replaced" file for reading */
2675 if (!RtlDosPathNameToNtPathName_U( replaced, &nt_replaced_name, NULL, NULL ))
2676 {
2678 return FALSE;
2679 }
2680 attr.ObjectName = &nt_replaced_name;
2681
2682 /* Replacement should fail if replaced is READ_ONLY */
2684 RtlFreeUnicodeString(&nt_replaced_name);
2685 if (!set_ntstatus( status )) return FALSE;
2686
2687 if (info.FileAttributes & FILE_ATTRIBUTE_READONLY)
2688 {
2690 return FALSE;
2691 }
2692
2693 /*
2694 * Open the replacement file for reading, writing, and deleting
2695 * (writing and deleting are needed when finished)
2696 */
2697 if (!RtlDosPathNameToNtPathName_U( replacement, &nt_replacement_name, NULL, NULL ))
2698 {
2700 return FALSE;
2701 }
2702 attr.ObjectName = &nt_replacement_name;
2705 RtlFreeUnicodeString(&nt_replacement_name);
2706 if (!set_ntstatus( status )) return FALSE;
2707 NtClose( hReplacement );
2708
2709 /* If the user wants a backup then that needs to be performed first */
2710 if (backup)
2711 {
2712 if (!MoveFileExW( replaced, backup, MOVEFILE_REPLACE_EXISTING )) return FALSE;
2713 }
2714 else
2715 {
2716 /* ReplaceFile() can replace an open target. To do this, we need to move
2717 * it out of the way first. */
2719
2720 lstrcpynW( temp_path, replaced, ARRAY_SIZE( temp_path ) );
2722 if (!GetTempFileNameW( temp_path, L"rf", 0, temp_file ) ||
2724 return FALSE;
2725
2727 }
2728
2729 /*
2730 * Now that the backup has been performed (if requested), copy the replacement
2731 * into place
2732 */
2733 if (!MoveFileExW( replacement, replaced, 0 ))
2734 {
2735 /* on failure we need to indicate whether a backup was made */
2736 if (!backup)
2738 else
2740 return FALSE;
2741 }
2742 return TRUE;
2743}
static long backup()
Definition: maze.c:403
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI MoveFileExW(const WCHAR *source, const WCHAR *dest, DWORD flag)
Definition: file.c:2531
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1145
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
#define WRITE_DAC
Definition: nt_native.h:59
Definition: fci.c:110
#define ERROR_UNABLE_TO_MOVE_REPLACEMENT
Definition: winerror.h:1022
#define ERROR_UNABLE_TO_MOVE_REPLACEMENT_2
Definition: winerror.h:1023

◆ SearchPathA()

DWORD WINAPI DECLSPEC_HOTPATCH SearchPathA ( LPCSTR  path,
LPCSTR  name,
LPCSTR  ext,
DWORD  buflen,
LPSTR  buffer,
LPSTR lastpart 
)

Definition at line 2749 of file file.c.

2751{
2752 WCHAR *pathW = NULL, *nameW, *extW = NULL;
2753 WCHAR bufferW[MAX_PATH];
2754 DWORD ret;
2755
2756 if (!name)
2757 {
2759 return 0;
2760 }
2761
2762 if (!(nameW = file_name_AtoW( name, FALSE ))) return 0;
2763 if (path && !(pathW = file_name_AtoW( path, TRUE ))) return 0;
2764 if (ext && !(extW = file_name_AtoW( ext, TRUE )))
2765 {
2766 RtlFreeHeap( GetProcessHeap(), 0, pathW );
2767 return 0;
2768 }
2769
2770 ret = SearchPathW( pathW, nameW, extW, MAX_PATH, bufferW, NULL );
2771
2772 RtlFreeHeap( GetProcessHeap(), 0, pathW );
2773 RtlFreeHeap( GetProcessHeap(), 0, extW );
2774
2775 if (!ret) return 0;
2776 if (ret > MAX_PATH)
2777 {
2779 return 0;
2780 }
2781 ret = copy_filename_WtoA( bufferW, buffer, buflen );
2782 if (buflen > ret && lastpart) *lastpart = strrchr(buffer, '\\') + 1;
2783 return ret;
2784}
DWORD WINAPI DECLSPEC_HOTPATCH SearchPathW(LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen, LPWSTR buffer, LPWSTR *lastpart)
Definition: file.c:2790
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)

◆ SearchPathW()

DWORD WINAPI DECLSPEC_HOTPATCH SearchPathW ( LPCWSTR  path,
LPCWSTR  name,
LPCWSTR  ext,
DWORD  buflen,
LPWSTR  buffer,
LPWSTR lastpart 
)

Definition at line 2790 of file file.c.

2792{
2793 DWORD ret = 0;
2794 WCHAR *name_ext;
2795
2796 if (!name || !name[0])
2797 {
2799 return 0;
2800 }
2801
2802 /* If the name contains an explicit path, ignore the path */
2803
2804 if (contains_path( name ))
2805 {
2806 /* try first without extension */
2807 if (RtlDoesFileExists_U( name )) return GetFullPathNameW( name, buflen, buffer, lastpart );
2808
2809 if ((name_ext = append_ext( name, ext )))
2810 {
2811 if (RtlDoesFileExists_U( name_ext ))
2812 ret = GetFullPathNameW( name_ext, buflen, buffer, lastpart );
2813 RtlFreeHeap( GetProcessHeap(), 0, name_ext );
2814 }
2815 }
2816 else if (path && path[0]) /* search in the specified path */
2817 {
2818 ret = RtlDosSearchPath_U( path, name, ext, buflen * sizeof(WCHAR),
2819 buffer, lastpart ) / sizeof(WCHAR);
2820 }
2821 else /* search in active context and default path */
2822 {
2823 WCHAR *dll_path = NULL, *name_ext = append_ext( name, ext );
2824
2825 if (name_ext) name = name_ext;
2826
2827 /* When file is found with activation context no attempt is made
2828 to check if it's really exist, path is returned only basing on context info. */
2829 if (find_actctx_dllpath( name, &dll_path ) == STATUS_SUCCESS)
2830 {
2831 ret = lstrlenW( dll_path ) + lstrlenW( name ) + 1;
2832
2833 /* count null termination char too */
2834 if (ret <= buflen)
2835 {
2836 lstrcpyW( buffer, dll_path );
2837 lstrcatW( buffer, name );
2838 if (lastpart) *lastpart = buffer + lstrlenW( dll_path );
2839 ret--;
2840 }
2841 else if (lastpart) *lastpart = NULL;
2842 RtlFreeHeap( GetProcessHeap(), 0, dll_path );
2843 }
2844 else if (!RtlGetSearchPath( &dll_path ))
2845 {
2846 ret = RtlDosSearchPath_U( dll_path, name, NULL, buflen * sizeof(WCHAR),
2847 buffer, lastpart ) / sizeof(WCHAR);
2848 RtlReleasePath( dll_path );
2849 }
2850 RtlFreeHeap( GetProcessHeap(), 0, name_ext );
2851 }
2852
2854 else TRACE( "found %s\n", debugstr_w(buffer) );
2855 return ret;
2856}
static NTSTATUS find_actctx_dllpath(const WCHAR *name, WCHAR **path)
Definition: file.c:269
static BOOL contains_path(const WCHAR *name)
Definition: file.c:102
static WCHAR * append_ext(const WCHAR *name, const WCHAR *ext)
Definition: file.c:243
NTSYSAPI NTSTATUS WINAPI RtlGetSearchPath(PWSTR *)
NTSYSAPI void WINAPI RtlReleasePath(PWSTR)
NTSYSAPI ULONG NTAPI RtlDosSearchPath_U(_In_ PCWSTR Path, _In_ PCWSTR FileName, _In_ PCWSTR Extension, _In_ ULONG BufferSize, _Out_ PWSTR Buffer, _Out_ PWSTR *PartName)
NTSYSAPI BOOLEAN NTAPI RtlDoesFileExists_U(_In_ PCWSTR FileName)

Referenced by SearchPathA().

◆ SetCommBreak()

BOOL WINAPI DECLSPEC_HOTPATCH SetCommBreak ( HANDLE  handle)

Definition at line 4454 of file file.c.

4455{
4457}
#define SETBREAK
Definition: winbase.h:264

◆ SetCommConfig()

BOOL WINAPI DECLSPEC_HOTPATCH SetCommConfig ( HANDLE  handle,
COMMCONFIG config,
DWORD  size 
)

Definition at line 4463 of file file.c.

4464{
4465 TRACE( "(%p, %p, %lu)\n", handle, config, size );
4466 return SetCommState( handle, &config->dcb );
4467}
BOOL WINAPI DECLSPEC_HOTPATCH SetCommState(HANDLE handle, DCB *dcb)
Definition: file.c:4483

◆ SetCommMask()

BOOL WINAPI DECLSPEC_HOTPATCH SetCommMask ( HANDLE  handle,
DWORD  mask 
)

Definition at line 4473 of file file.c.

4474{
4476 NULL, 0, NULL, NULL );
4477}
#define IOCTL_SERIAL_SET_WAIT_MASK
Definition: ntddser.h:106

◆ SetCommState()

BOOL WINAPI DECLSPEC_HOTPATCH SetCommState ( HANDLE  handle,
DCB dcb 
)

Definition at line 4483 of file file.c.

4484{
4485 SERIAL_BAUD_RATE sbr;
4487 SERIAL_HANDFLOW shf;
4488 SERIAL_CHARS sc;
4489
4490 if (!dcb)
4491 {
4493 return FALSE;
4494 }
4495 dump_dcb( dcb );
4496
4497 sbr.BaudRate = dcb->BaudRate;
4498 slc.StopBits = dcb->StopBits;
4499 slc.Parity = dcb->Parity;
4500 slc.WordLength = dcb->ByteSize;
4501 shf.ControlHandShake = 0;
4502 shf.FlowReplace = 0;
4503 if (dcb->fOutxCtsFlow) shf.ControlHandShake |= SERIAL_CTS_HANDSHAKE;
4504 if (dcb->fOutxDsrFlow) shf.ControlHandShake |= SERIAL_DSR_HANDSHAKE;
4505 switch (dcb->fDtrControl)
4506 {
4507 case DTR_CONTROL_DISABLE: break;
4510 default:
4512 return FALSE;
4513 }
4514 switch (dcb->fRtsControl)
4515 {
4516 case RTS_CONTROL_DISABLE: break;
4520 default:
4522 return FALSE;
4523 }
4524 if (dcb->fDsrSensitivity) shf.ControlHandShake |= SERIAL_DSR_SENSITIVITY;
4525 if (dcb->fAbortOnError) shf.ControlHandShake |= SERIAL_ERROR_ABORT;
4526 if (dcb->fErrorChar) shf.FlowReplace |= SERIAL_ERROR_CHAR;
4527 if (dcb->fNull) shf.FlowReplace |= SERIAL_NULL_STRIPPING;
4528 if (dcb->fTXContinueOnXoff) shf.FlowReplace |= SERIAL_XOFF_CONTINUE;
4529 if (dcb->fOutX) shf.FlowReplace |= SERIAL_AUTO_TRANSMIT;
4530 if (dcb->fInX) shf.FlowReplace |= SERIAL_AUTO_RECEIVE;
4531 shf.XonLimit = dcb->XonLim;
4532 shf.XoffLimit = dcb->XoffLim;
4533 sc.EofChar = dcb->EofChar;
4534 sc.ErrorChar = dcb->ErrorChar;
4535 sc.BreakChar = 0;
4536 sc.EventChar = dcb->EvtChar;
4537 sc.XonChar = dcb->XonChar;
4538 sc.XoffChar = dcb->XoffChar;
4539
4540 /* note: change DTR/RTS lines after setting the comm attributes,
4541 * so flow control does not interfere.
4542 */
4543 return (DeviceIoControl( handle, IOCTL_SERIAL_SET_BAUD_RATE, &sbr, sizeof(sbr), NULL, 0, NULL, NULL ) &&
4544 DeviceIoControl( handle, IOCTL_SERIAL_SET_LINE_CONTROL, &slc, sizeof(slc), NULL, 0, NULL, NULL ) &&
4545 DeviceIoControl( handle, IOCTL_SERIAL_SET_HANDFLOW, &shf, sizeof(shf), NULL, 0, NULL, NULL ) &&
4546 DeviceIoControl( handle, IOCTL_SERIAL_SET_CHARS, &sc, sizeof(sc), NULL, 0, NULL, NULL ));
4547}
#define IOCTL_SERIAL_SET_CHARS
Definition: ntddser.h:88
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
#define IOCTL_SERIAL_SET_HANDFLOW
Definition: ntddser.h:94
UCHAR BreakChar
Definition: ntddser.h:164

Referenced by SetCommConfig().

◆ SetCommTimeouts()

BOOL WINAPI DECLSPEC_HOTPATCH SetCommTimeouts ( HANDLE  handle,
COMMTIMEOUTS timeouts 
)

Definition at line 4553 of file file.c.

4554{
4555 if (!timeouts)
4556 {
4558 return FALSE;
4559 }
4561 NULL, 0, NULL, NULL );
4562}
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104

◆ SetCurrentDirectoryA()

BOOL WINAPI DECLSPEC_HOTPATCH SetCurrentDirectoryA ( LPCSTR  dir)

Definition at line 2862 of file file.c.

2863{
2864 WCHAR *dirW;
2866
2867 if (!(dirW = file_name_AtoW( dir, FALSE ))) return FALSE;
2868 RtlInitUnicodeString( &strW, dirW );
2870}
NTSYSAPI NTSTATUS NTAPI RtlSetCurrentDirectory_U(_In_ PUNICODE_STRING name)

Referenced by test_CreateFileA(), test_FindFirstFile_wildcards(), and test_RemoveDirectory().

◆ SetCurrentDirectoryW()

BOOL WINAPI DECLSPEC_HOTPATCH SetCurrentDirectoryW ( LPCWSTR  dir)

Definition at line 2876 of file file.c.

2877{
2878 UNICODE_STRING dirW;
2879
2880 RtlInitUnicodeString( &dirW, dir );
2881 return set_ntstatus( RtlSetCurrentDirectory_U( &dirW ));
2882}

Referenced by test_CreateFileA().

◆ SetEndOfFile()

BOOL WINAPI DECLSPEC_HOTPATCH SetEndOfFile ( HANDLE  file)

Definition at line 3651 of file file.c.

3652{
3657
3659 {
3660 eof.EndOfFile = pos.CurrentByteOffset;
3662 }
3663 return set_ntstatus( status );
3664}
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileEndOfFileInformation
Definition: from_kernel.h:81
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

Referenced by _chsize_s(), test_read_write(), and test_SetFileValidData().

◆ SetFileApisToANSI()

void WINAPI DECLSPEC_HOTPATCH SetFileApisToANSI ( void  )

Definition at line 2888 of file file.c.

2889{
2891}

◆ SetFileApisToOEM()

void WINAPI DECLSPEC_HOTPATCH SetFileApisToOEM ( void  )

Definition at line 2897 of file file.c.

2898{
2900}

Referenced by _tmain().

◆ SetFileAttributesA()

BOOL WINAPI DECLSPEC_HOTPATCH SetFileAttributesA ( LPCSTR  name,
DWORD  attributes 
)

Definition at line 2906 of file file.c.

2907{
2908 WCHAR *nameW;
2909
2910 if (!(nameW = file_name_AtoW( name, FALSE ))) return FALSE;
2911 return SetFileAttributesW( nameW, attributes );
2912}
BOOL WINAPI DECLSPEC_HOTPATCH SetFileAttributesW(LPCWSTR name, DWORD attributes)
Definition: file.c:2918

Referenced by _chmod(), test__creat(), test__hread(), test__lcreat(), test_file_disposition_information(), test_Mapfile_createtemp(), and test_ReplaceFileA().

◆ SetFileAttributesW()

BOOL WINAPI DECLSPEC_HOTPATCH SetFileAttributesW ( LPCWSTR  name,
DWORD  attributes 
)

Definition at line 2918 of file file.c.

2919{
2920 UNICODE_STRING nt_name;
2924 HANDLE handle;
2925
2926 TRACE( "%s %lx\n", debugstr_w(name), attributes );
2927
2928 if (!RtlDosPathNameToNtPathName_U( name, &nt_name, NULL, NULL ))
2929 {
2931 return FALSE;
2932 }
2933
2934 attr.Length = sizeof(attr);
2935 attr.RootDirectory = 0;
2936 attr.Attributes = OBJ_CASE_INSENSITIVE;
2937 attr.ObjectName = &nt_name;
2938 attr.SecurityDescriptor = NULL;
2939 attr.SecurityQualityOfService = NULL;
2940
2942 RtlFreeUnicodeString( &nt_name );
2943
2944 if (status == STATUS_SUCCESS)
2945 {
2947
2948 memset( &info, 0, sizeof(info) );
2949 info.FileAttributes = attributes | FILE_ATTRIBUTE_NORMAL; /* make sure it's not zero */
2951 NtClose( handle );
2952 }
2953 return set_ntstatus( status );
2954}

Referenced by _wchmod(), SetFileAttributesA(), test_NtCreateFile(), test_readonly(), and test_ReplaceFileW().

◆ SetFileInformationByHandle()

BOOL WINAPI DECLSPEC_HOTPATCH SetFileInformationByHandle ( HANDLE  file,
FILE_INFO_BY_HANDLE_CLASS  class,
void info,
DWORD  size 
)

Definition at line 3670 of file file.c.

3672{
3675
3676 TRACE( "%p %u %p %lu\n", file, class, info, size );
3677
3678 switch (class)
3679 {
3680 case FileNameInfo:
3681 case FileAllocationInfo:
3682 case FileStreamInfo:
3683 case FileIdBothDirectoryInfo:
3684 case FileIdBothDirectoryRestartInfo:
3685 case FileFullDirectoryInfo:
3686 case FileFullDirectoryRestartInfo:
3687 case FileStorageInfo:
3688 case FileAlignmentInfo:
3689 case FileIdInfo:
3690 case FileIdExtdDirectoryInfo:
3691 case FileIdExtdDirectoryRestartInfo:
3692 FIXME( "%p, %u, %p, %lu\n", file, class, info, size );
3694 return FALSE;
3695
3696 case FileEndOfFileInfo:
3698 break;
3699 case FileBasicInfo:
3701 break;
3702 case FileDispositionInfo:
3704 break;
3705 case FileDispositionInfoEx:
3707 break;
3708 case FileIoPriorityHintInfo:
3710 break;
3711 case FileRenameInfo:
3712 {
3713 FILE_RENAME_INFORMATION *rename_info;
3714 UNICODE_STRING nt_name;
3715 ULONG size;
3716
3718 &nt_name, NULL, NULL )))
3719 break;
3720
3721 size = sizeof(*rename_info) + nt_name.Length;
3722 if ((rename_info = HeapAlloc( GetProcessHeap(), 0, size )))
3723 {
3724 memcpy( rename_info, info, sizeof(*rename_info) );
3725 memcpy( rename_info->FileName, nt_name.Buffer, nt_name.Length + sizeof(WCHAR) );
3726 rename_info->FileNameLength = nt_name.Length;
3728 HeapFree( GetProcessHeap(), 0, rename_info );
3729 }
3730 RtlFreeUnicodeString( &nt_name );
3731 break;
3732 }
3733 case FileStandardInfo:
3734 case FileCompressionInfo:
3735 case FileAttributeTagInfo:
3736 case FileRemoteProtocolInfo:
3737 default:
3739 return FALSE;
3740 }
3741 return set_ntstatus( status );
3742}
#define FileDispositionInformationEx
Definition: fileinfo.c:26
@ FileIoPriorityHintInformation
Definition: from_kernel.h:104

◆ SetFilePointer()

DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer ( HANDLE  file,
LONG  distance,
LONG highword,
DWORD  method 
)

Definition at line 3748 of file file.c.

3749{
3750 LARGE_INTEGER dist, newpos;
3751
3752 if (highword)
3753 {
3754 dist.u.LowPart = distance;
3755 dist.u.HighPart = *highword;
3756 }
3757 else dist.QuadPart = distance;
3758
3759 if (!SetFilePointerEx( file, dist, &newpos, method )) return INVALID_SET_FILE_POINTER;
3760
3761 if (highword) *highword = newpos.u.HighPart;
3762 if (newpos.u.LowPart == INVALID_SET_FILE_POINTER) SetLastError( 0 );
3763 return newpos.u.LowPart;
3764}
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
BOOL WINAPI DECLSPEC_HOTPATCH SetFilePointerEx(HANDLE file, LARGE_INTEGER distance, LARGE_INTEGER *newpos, DWORD method)
Definition: file.c:3770
method
Definition: dragdrop.c:54
GLsizei GLsizei GLfloat distance
Definition: glext.h:11755

◆ SetFilePointerEx()

BOOL WINAPI DECLSPEC_HOTPATCH SetFilePointerEx ( HANDLE  file,
LARGE_INTEGER  distance,
LARGE_INTEGER newpos,
DWORD  method 
)

Definition at line 3770 of file file.c.

3772{
3773 LONGLONG pos;
3777
3778 switch(method)
3779 {
3780 case FILE_BEGIN:
3781 pos = distance.QuadPart;
3782 break;
3783 case FILE_CURRENT:
3785 goto error;
3786 pos = info.CurrentByteOffset.QuadPart + distance.QuadPart;
3787 break;
3788 case FILE_END:
3790 goto error;
3791 pos = eof.EndOfFile.QuadPart + distance.QuadPart;
3792 break;
3793 default:
3795 return FALSE;
3796 }
3797
3798 if (pos < 0)
3799 {
3801 return FALSE;
3802 }
3803
3804 info.CurrentByteOffset.QuadPart = pos;
3806 {
3807 if (newpos) newpos->QuadPart = pos;
3808 return TRUE;
3809 }
3810
3811error:
3812 return set_ntstatus( io.Status );
3813}
#define FILE_BEGIN
Definition: compat.h:761
int64_t LONGLONG
Definition: typedefs.h:68
#define FILE_END
Definition: winbase.h:122
#define FILE_CURRENT
Definition: winbase.h:121
#define ERROR_NEGATIVE_SEEK
Definition: winerror.h:326

Referenced by SetFilePointer().

◆ SetFileTime()

BOOL WINAPI DECLSPEC_HOTPATCH SetFileTime ( HANDLE  file,
const FILETIME ctime,
const FILETIME atime,
const FILETIME mtime 
)

Definition at line 3819 of file file.c.

3821{
3824
3825 memset( &info, 0, sizeof(info) );
3826 if (ctime)
3827 {
3828 info.CreationTime.u.HighPart = ctime->dwHighDateTime;
3829 info.CreationTime.u.LowPart = ctime->dwLowDateTime;
3830 }
3831 if (atime)
3832 {
3833 info.LastAccessTime.u.HighPart = atime->dwHighDateTime;
3834 info.LastAccessTime.u.LowPart = atime->dwLowDateTime;
3835 }
3836 if (mtime)
3837 {
3838 info.LastWriteTime.u.HighPart = mtime->dwHighDateTime;
3839 info.LastWriteTime.u.LowPart = mtime->dwLowDateTime;
3840 }
3841
3843}
__u16 ctime
Definition: mkdosfs.c:4

Referenced by test_CopyFile2(), test_CopyFileA(), test_CreateFile(), and test_ReplaceFileA().

◆ SetFileValidData()

BOOL WINAPI DECLSPEC_HOTPATCH SetFileValidData ( HANDLE  file,
LONGLONG  length 
)

Definition at line 3849 of file file.c.

3850{
3853
3854 info.ValidDataLength.QuadPart = length;
3855 return set_ntstatus( NtSetInformationFile( file, &io, &info, sizeof(info),
3857}
@ FileValidDataLengthInformation
Definition: from_kernel.h:100
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

◆ SetLocalTime()

BOOL WINAPI DECLSPEC_HOTPATCH SetLocalTime ( const SYSTEMTIME systime)

Definition at line 4125 of file file.c.

4126{
4127 FILETIME ft;
4128 LARGE_INTEGER st;
4129
4130 if (!SystemTimeToFileTime( systime, &ft )) return FALSE;
4132 return set_ntstatus( NtSetSystemTime( &st, NULL ));
4133}
BOOL WINAPI DECLSPEC_HOTPATCH SystemTimeToFileTime(const SYSTEMTIME *systime, FILETIME *ft)
Definition: file.c:4164
NTSTATUS NTAPI NtSetSystemTime(IN PLARGE_INTEGER SystemTime, OUT PLARGE_INTEGER PreviousTime OPTIONAL)
Definition: time.c:458

◆ SetSystemTime()

BOOL WINAPI DECLSPEC_HOTPATCH SetSystemTime ( const SYSTEMTIME systime)

Definition at line 4139 of file file.c.

4140{
4141 FILETIME ft;
4142
4143 if (!SystemTimeToFileTime( systime, &ft )) return FALSE;
4144 return set_ntstatus( NtSetSystemTime( (LARGE_INTEGER *)&ft, NULL ));
4145}

◆ SetSystemTimeAdjustment()

BOOL WINAPI DECLSPEC_HOTPATCH SetSystemTimeAdjustment ( DWORD  adjust,
BOOL  disabled 
)

Definition at line 4151 of file file.c.

4152{
4154
4155 st.TimeAdjustment = adjust;
4156 st.TimeAdjustmentDisabled = disabled;
4158}
NTSYSAPI NTSTATUS NTAPI NtSetSystemInformation(IN INT SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
BOOLEAN TimeAdjustmentDisabled
Definition: winternl.h:3210

◆ SetupComm()

BOOL WINAPI DECLSPEC_HOTPATCH SetupComm ( HANDLE  handle,
DWORD  in_size,
DWORD  out_size 
)

Definition at line 4568 of file file.c.

4569{
4571
4572 sqs.InSize = in_size;
4573 sqs.OutSize = out_size;
4574 return DeviceIoControl( handle, IOCTL_SERIAL_SET_QUEUE_SIZE, &sqs, sizeof(sqs), NULL, 0, NULL, NULL );
4575}
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
Definition: file.c:100
#define IOCTL_SERIAL_SET_QUEUE_SIZE
Definition: ntddser.h:100

◆ SystemTimeToFileTime()

BOOL WINAPI DECLSPEC_HOTPATCH SystemTimeToFileTime ( const SYSTEMTIME systime,
FILETIME ft 
)

Definition at line 4164 of file file.c.

4165{
4167
4168 tf.Year = systime->wYear;
4169 tf.Month = systime->wMonth;
4170 tf.Day = systime->wDay;
4171 tf.Hour = systime->wHour;
4172 tf.Minute = systime->wMinute;
4173 tf.Second = systime->wSecond;
4174 tf.Milliseconds = systime->wMilliseconds;
4175 if (RtlTimeFieldsToTime( &tf, (LARGE_INTEGER *)ft )) return TRUE;
4177 return FALSE;
4178}
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)

Referenced by SetLocalTime(), and SetSystemTime().

◆ TransmitCommChar()

BOOL WINAPI DECLSPEC_HOTPATCH TransmitCommChar ( HANDLE  handle,
CHAR  ch 
)

Definition at line 4581 of file file.c.

4582{
4583 return DeviceIoControl( handle, IOCTL_SERIAL_IMMEDIATE_CHAR, &ch, sizeof(ch), NULL, 0, NULL, NULL );
4584}
#define IOCTL_SERIAL_IMMEDIATE_CHAR
Definition: ntddser.h:74

◆ UnlockFile()

BOOL WINAPI DECLSPEC_HOTPATCH UnlockFile ( HANDLE  file,
DWORD  offset_low,
DWORD  offset_high,
DWORD  count_low,
DWORD  count_high 
)

Definition at line 3863 of file file.c.

3865{
3867
3868 count.u.LowPart = count_low;
3869 count.u.HighPart = count_high;
3870 offset.u.LowPart = offset_low;
3871 offset.u.HighPart = offset_high;
3873}
NTSTATUS NTAPI NtUnlockFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER ByteOffset, IN PLARGE_INTEGER Length, IN ULONG Key OPTIONAL)
Definition: iofunc.c:3551

Referenced by _locking(), test_LockFile(), and UnlockFileEx().

◆ UnlockFileEx()

BOOL WINAPI DECLSPEC_HOTPATCH UnlockFileEx ( HANDLE  file,
DWORD  reserved,
DWORD  count_low,
DWORD  count_high,
LPOVERLAPPED  overlapped 
)

Definition at line 3879 of file file.c.

3881{
3882 if (reserved)
3883 {
3885 return FALSE;
3886 }
3887 if (overlapped->hEvent) FIXME("Unimplemented overlapped operation\n");
3888
3889 return UnlockFile( file, overlapped->Offset, overlapped->OffsetHigh, count_low, count_high );
3890}
BOOL WINAPI DECLSPEC_HOTPATCH UnlockFile(HANDLE file, DWORD offset_low, DWORD offset_high, DWORD count_low, DWORD count_high)
Definition: file.c:3863

Referenced by test_LockFile().

◆ WaitCommEvent()

BOOL WINAPI DECLSPEC_HOTPATCH WaitCommEvent ( HANDLE  handle,
DWORD events,
OVERLAPPED overlapped 
)

Definition at line 4590 of file file.c.

4591{
4593 NULL, overlapped );
4594}
HANDLE events[2]
Definition: event.c:4
#define IOCTL_SERIAL_WAIT_ON_MASK
Definition: ntddser.h:112

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( file  )

◆ Wow64DisableWow64FsRedirection()

BOOL WINAPI DECLSPEC_HOTPATCH Wow64DisableWow64FsRedirection ( PVOID old_value)

Definition at line 2960 of file file.c.

2961{
2963}
NTSYSAPI NTSTATUS NTAPI RtlWow64EnableFsRedirectionEx(IN PVOID Wow64FsEnableRedirection, OUT PVOID *OldFsRedirectionLevel)
Definition: libsupp.c:1178
static ULONG * old_value
Definition: directory.c:54

◆ Wow64RevertWow64FsRedirection()

BOOL WINAPI DECLSPEC_HOTPATCH Wow64RevertWow64FsRedirection ( PVOID  old_value)

Definition at line 2980 of file file.c.

2981{
2983}

◆ WriteFile()

BOOL WINAPI DECLSPEC_HOTPATCH WriteFile ( HANDLE  file,
LPCVOID  buffer,
DWORD  count,
LPDWORD  result,
LPOVERLAPPED  overlapped 
)

Definition at line 3896 of file file.c.

3898{
3899 HANDLE event = NULL;
3901 PLARGE_INTEGER poffset = NULL;
3904 PIO_STATUS_BLOCK piosb = &iosb;
3905 LPVOID cvalue = NULL;
3906
3907 TRACE( "%p %p %ld %p %p\n", file, buffer, count, result, overlapped );
3908
3909 if (overlapped)
3910 {
3911 offset.u.LowPart = overlapped->Offset;
3912 offset.u.HighPart = overlapped->OffsetHigh;
3913 poffset = &offset;
3914 event = overlapped->hEvent;
3916 if (((ULONG_PTR)event & 1) == 0) cvalue = overlapped;
3917 }
3918 else piosb->Information = 0;
3919 piosb->Status = STATUS_PENDING;
3920
3921 status = NtWriteFile( file, event, NULL, cvalue, piosb, buffer, count, poffset, NULL );
3922
3923 if (status == STATUS_PENDING && !overlapped)
3924 {
3926 status = piosb->Status;
3927 }
3928
3929 if (result) *result = overlapped && status ? 0 : piosb->Information;
3930
3931 if (status && status != STATUS_TIMEOUT)
3932 {
3934 return FALSE;
3935 }
3936 return TRUE;
3937}
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)

Referenced by _write(), _wsopen_s(), copy_file(), create_fake_dll(), open_file_test(), test_CopyFile2(), test_CopyFileA(), test_CreateFile(), test_file_access(), test_file_completion_information(), test_get_osfhandle(), test_GetFileInformationByHandleEx(), test_iocp_fileio(), test_LockFile(), test_MoveFileA(), test_offset_in_overlapped_structure(), test_OpenFileById(), test_read_write(), test_ReplaceFileA(), test_SetFileValidData(), and transfer_file_http().

◆ WriteFileEx()

BOOL WINAPI DECLSPEC_HOTPATCH WriteFileEx ( HANDLE  file,
LPCVOID  buffer,
DWORD  count,
LPOVERLAPPED  overlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  completion 
)

Definition at line 3943 of file file.c.

3946{
3950
3951 TRACE( "%p %p %ld %p %p\n", file, buffer, count, overlapped, completion );
3952
3953 if (!overlapped)
3954 {
3956 return FALSE;
3957 }
3958 offset.u.LowPart = overlapped->Offset;
3959 offset.u.HighPart = overlapped->OffsetHigh;
3960
3962 io->Status = STATUS_PENDING;
3963 io->Information = 0;
3964
3966 if (status == STATUS_PENDING) return TRUE;
3967 return set_ntstatus( status );
3968}

◆ WriteFileGather()

BOOL WINAPI DECLSPEC_HOTPATCH WriteFileGather ( HANDLE  file,
FILE_SEGMENT_ELEMENT segments,
DWORD  count,
LPDWORD  reserved,
LPOVERLAPPED  overlapped 
)

Definition at line 3974 of file file.c.

3976{
3979 void *cvalue = NULL;
3980
3981 TRACE( "%p %p %lu %p\n", file, segments, count, overlapped );
3982
3983 offset.u.LowPart = overlapped->Offset;
3984 offset.u.HighPart = overlapped->OffsetHigh;
3985 if (!((ULONG_PTR)overlapped->hEvent & 1)) cvalue = overlapped;
3987 io->Status = STATUS_PENDING;
3988 io->Information = 0;
3989
3990 return set_ntstatus( NtWriteFileGather( file, overlapped->hEvent, NULL, cvalue,
3991 io, segments, count, &offset, NULL ));
3992}
NTSTATUS NTAPI NtWriteFileGather(IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, IN PVOID UserApcContext OPTIONAL, OUT PIO_STATUS_BLOCK UserIoStatusBlock, IN FILE_SEGMENT_ELEMENT BufferDescription[], IN ULONG BufferLength, IN PLARGE_INTEGER ByteOffset, IN PULONG Key OPTIONAL)
Definition: iofunc.c:4132

Referenced by test_WriteFileGather().

Variable Documentation

◆ dummy_iosb

IO_STATUS_BLOCK dummy_iosb
static

Definition at line 1062 of file file.c.

Referenced by FindFirstChangeNotificationW(), and FindNextChangeNotification().

◆ max_entry_size

const UINT max_entry_size = offsetof( FILE_BOTH_DIRECTORY_INFORMATION, FileName[256] )
static

Definition at line 65 of file file.c.

Referenced by FindFirstFileExW().

◆ oem_file_apis

BOOL oem_file_apis
static

◆ system_dir

◆ windows_dir

const WCHAR windows_dir[] = L"C:\\windows"