From 18411a19b4ea3a68234980c56d4c252670dfc000 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 31 Mar 2020 11:37:58 +0200 Subject: [PATCH] ntdll: Use wcscpy() instead of strcpyW(). Signed-off-by: Alexandre Julliard --- dlls/ntdll/actctx.c | 24 ++++++++++++------------ dlls/ntdll/directory.c | 2 +- dlls/ntdll/env.c | 6 +++--- dlls/ntdll/file.c | 1 - dlls/ntdll/loader.c | 16 ++++++++-------- dlls/ntdll/loadorder.c | 4 ++-- dlls/ntdll/locale.c | 8 ++++---- dlls/ntdll/ntdll_misc.h | 1 + dlls/ntdll/path.c | 6 +++--- dlls/ntdll/reg.c | 2 +- dlls/ntdll/relay.c | 2 +- dlls/ntdll/rtl.c | 3 +-- dlls/ntdll/sec.c | 1 - dlls/ntdll/time.c | 2 +- dlls/ntdll/version.c | 4 ++-- 15 files changed, 40 insertions(+), 42 deletions(-) diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index b6306fdbac5..03a18a1928c 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -737,7 +737,7 @@ static WCHAR *strdupW(const WCHAR* str) if (!(ptr = RtlAllocateHeap(GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR)))) return NULL; - return strcpyW(ptr, str); + return wcscpy(ptr, str); } static WCHAR *xmlstrdupW(const xmlstr_t* str) @@ -1098,7 +1098,7 @@ static WCHAR *build_assembly_dir(struct assembly_identity* ai) if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, size ))) return NULL; - strcpyW( ret, arch ); + wcscpy( ret, arch ); strcatW( ret, undW ); strcatW( ret, name ); strcatW( ret, undW ); @@ -1121,7 +1121,7 @@ static inline void append_string( WCHAR *buffer, const WCHAR *prefix, const WCHA strcatW( buffer, prefix ); p += strlenW(p); *p++ = '"'; - strcpyW( p, str ); + wcscpy( p, str ); p += strlenW(p); *p++ = '"'; *p = 0; @@ -1152,7 +1152,7 @@ static WCHAR *build_assembly_id( const struct assembly_identity *ai ) if (!(ret = RtlAllocateHeap( GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR) ))) return NULL; - if (ai->name) strcpyW( ret, ai->name ); + if (ai->name) wcscpy( ret, ai->name ); else *ret = 0; append_string( ret, archW, ai->arch ); append_string( ret, public_keyW, ai->public_key ); @@ -3074,7 +3074,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl, if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, (strlenW(filename) + 10) * sizeof(WCHAR) + sizeof(dotManifestW) ))) return STATUS_NO_MEMORY; - strcpyW( buffer, filename ); + wcscpy( buffer, filename ); if (resid != 1) NTDLL_swprintf( buffer + strlenW(buffer), fmtW, resid ); strcatW( buffer, dotManifestW ); RtlInitUnicodeString( &nameW, buffer ); @@ -3193,7 +3193,7 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit strlenW(user_shared_data->NtSystemRoot) * sizeof(WCHAR) ))) return STATUS_NO_MEMORY; - strcpyW( path, user_shared_data->NtSystemRoot ); + wcscpy( path, user_shared_data->NtSystemRoot ); memcpy( path + strlenW(path), manifest_dirW, sizeof(manifest_dirW) ); if (!RtlDosPathNameToNtPathName_U( path, &path_us, NULL, NULL )) @@ -3233,7 +3233,7 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit } path[path_us.Length/sizeof(WCHAR)] = '\\'; - strcpyW( path + path_us.Length/sizeof(WCHAR) + 1, file ); + wcscpy( path + path_us.Length/sizeof(WCHAR) + 1, file ); RtlInitUnicodeString( &path_us, path ); *strrchrW(file, '.') = 0; /* remove .manifest extension */ @@ -3289,7 +3289,7 @@ static NTSTATUS lookup_assembly(struct actctx_loader* acl, * First 'appdir' is used as , if that failed * it tries application manifest file path. */ - strcpyW( buffer, acl->actctx->appdir.info ); + wcscpy( buffer, acl->actctx->appdir.info ); p = buffer + strlenW(buffer); for (i = 0; i < 4; i++) { @@ -3300,10 +3300,10 @@ static NTSTATUS lookup_assembly(struct actctx_loader* acl, } else *p++ = '\\'; - strcpyW( p, ai->name ); + wcscpy( p, ai->name ); p += strlenW(p); - strcpyW( p, dotDllW ); + wcscpy( p, dotDllW ); if (RtlDosPathNameToNtPathName_U( buffer, &nameW, NULL, NULL )) { status = open_nt_file( &file, &nameW ); @@ -3318,7 +3318,7 @@ static NTSTATUS lookup_assembly(struct actctx_loader* acl, RtlFreeUnicodeString( &nameW ); } - strcpyW( p, dotManifestW ); + wcscpy( p, dotManifestW ); if (RtlDosPathNameToNtPathName_U( buffer, &nameW, NULL, NULL )) { status = open_nt_file( &file, &nameW ); @@ -5604,6 +5604,6 @@ NTSTATUS WINAPI RtlQueryActivationContextApplicationSettings( DWORD flags, HANDL if (written) *written = strlenW(res) + 1; if (size < strlenW(res)) return STATUS_BUFFER_TOO_SMALL; - strcpyW( buffer, res ); + wcscpy( buffer, res ); return STATUS_SUCCESS; } diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index d025a37241a..8f945c972c9 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -348,7 +348,7 @@ static const char *add_dir_data_nameA( struct dir_data *data, const char *name ) static const WCHAR *add_dir_data_nameW( struct dir_data *data, const WCHAR *name ) { WCHAR *ptr = get_dir_data_space( data, (strlenW( name ) + 1) * sizeof(WCHAR) ); - if (ptr) strcpyW( ptr, name ); + if (ptr) wcscpy( ptr, name ); return ptr; } diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index 085a260ea6a..ecc2c38abb8 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -709,7 +709,7 @@ static void get_image_path( const char *argv0, UNICODE_STRING *path ) /* build builtin path inside system directory */ len = strlenW( system_dir ); if (strlenW( name ) >= MAX_PATH - 4 - len) goto failed; - strcpyW( full_name, system_dir ); + wcscpy( full_name, system_dir ); strcatW( full_name, name ); if (!strchrW( name, '.' )) strcatW( full_name, exeW ); } @@ -744,7 +744,7 @@ static void set_library_wargv( char **argv, const UNICODE_STRING *image ) p = (WCHAR *)(wargv + argc + 1); if (image) { - strcpyW( p, image->Buffer ); + wcscpy( p, image->Buffer ); wargv[0] = p; p += 1 + image->Length / sizeof(WCHAR); total -= 1 + image->Length / sizeof(WCHAR); @@ -831,7 +831,7 @@ static void build_command_line( WCHAR **argv, UNICODE_STRING *cmdline ) } else { - strcpyW( p, *arg ); + wcscpy( p, *arg ); p += strlenW( p ); } if (has_space) diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index bd27d5a4349..37e697c8c6d 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -99,7 +99,6 @@ #include "ntstatus.h" #define WIN32_NO_STATUS #define NONAMELESSUNION -#include "wine/unicode.h" #include "wine/debug.h" #include "wine/server.h" #include "ntdll_misc.h" diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 4d4d806d457..f67e1357ad3 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1774,7 +1774,7 @@ static BOOL get_builtin_fullname( UNICODE_STRING *nt_name, const UNICODE_STRING if (!(fullname = RtlAllocateHeap( GetProcessHeap(), 0, (strlenW(system_dir) + len + 5) * sizeof(WCHAR) ))) return FALSE; - strcpyW( fullname, nt_prefixW ); + wcscpy( fullname, nt_prefixW ); strcatW( fullname, system_dir ); strcatW( fullname, filenameW ); done: @@ -2235,7 +2235,7 @@ static NTSTATUS get_dll_load_path_search_flags( LPCWSTR module, DWORD flags, WCH p = append_path( p, dir->dir + 4 /* \??\ */, -1 ); p = append_path( p, dll_directory.Buffer, dll_directory.Length / sizeof(WCHAR) ); } - if (flags & LOAD_LIBRARY_SEARCH_SYSTEM32) strcpyW( p, system_dir ); + if (flags & LOAD_LIBRARY_SEARCH_SYSTEM32) wcscpy( p, system_dir ); else { if (p > ret) p--; @@ -2781,7 +2781,7 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname ) } memcpy( p, info->lpAssemblyManifestPath, dirlen * sizeof(WCHAR) ); p += dirlen; - strcpyW( p, libname ); + wcscpy( p, libname ); goto done; } } @@ -2800,14 +2800,14 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname ) status = STATUS_NO_MEMORY; goto done; } - strcpyW( p, user_shared_data->NtSystemRoot ); + wcscpy( p, user_shared_data->NtSystemRoot ); p += strlenW(p); memcpy( p, winsxsW, sizeof(winsxsW) ); p += ARRAY_SIZE( winsxsW ); memcpy( p, info->lpAssemblyDirectoryName, info->ulAssemblyDirectoryNameLength ); p += info->ulAssemblyDirectoryNameLength / sizeof(WCHAR); *p++ = '\\'; - strcpyW( p, libname ); + wcscpy( p, libname ); done: RtlFreeHeap( GetProcessHeap(), 0, info ); RtlReleaseActivationContext( data.hActCtx ); @@ -2844,7 +2844,7 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING * if (*ptr == ';') ptr++; memcpy( name, paths, len * sizeof(WCHAR) ); if (len && name[len - 1] != '\\') name[len++] = '\\'; - strcpyW( name + len, search ); + wcscpy( name + len, search ); nt_name->Buffer = NULL; if ((status = RtlDosPathNameToNtPathName_U_WithStatus( name, nt_name, NULL, NULL ))) goto done; @@ -2859,7 +2859,7 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING * if (!found_image) { /* not found, return file in the system dir to be loaded as builtin */ - strcpyW( name, system_dir ); + wcscpy( name, system_dir ); strcatW( name, search ); if (!RtlDosPathNameToNtPathName_U( name, nt_name, NULL, NULL )) status = STATUS_NO_MEMORY; } @@ -2895,7 +2895,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, con if (!(dllname = RtlAllocateHeap( GetProcessHeap(), 0, (strlenW(libname)+strlenW(default_ext)+1) * sizeof(WCHAR)))) return STATUS_NO_MEMORY; - strcpyW( dllname, libname ); + wcscpy( dllname, libname ); strcatW( dllname, default_ext ); libname = dllname; } diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c index 8c540f96832..35dd321e994 100644 --- a/dlls/ntdll/loadorder.c +++ b/dlls/ntdll/loadorder.c @@ -343,7 +343,7 @@ static HANDLE get_app_key( const WCHAR *app_name ) sizeof(AppDefaultsW) + sizeof(DllOverridesW) + strlenW(app_name) * sizeof(WCHAR) ); if (!str) return 0; - strcpyW( str, AppDefaultsW ); + wcscpy( str, AppDefaultsW ); strcatW( str, app_name ); strcatW( str, DllOverridesW ); @@ -454,7 +454,7 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n if (!(len = strlenW(path))) return ret; if (!(module = RtlAllocateHeap( GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR) ))) return ret; - strcpyW( module+1, path ); /* reserve module[0] for the wildcard char */ + wcscpy( module+1, path ); /* reserve module[0] for the wildcard char */ remove_dll_ext( module + 1 ); basename = (WCHAR *)get_basename( module+1 ); diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c index 63d0bf3e98a..1487338cfab 100644 --- a/dlls/ntdll/locale.c +++ b/dlls/ntdll/locale.c @@ -849,7 +849,7 @@ static LCID unix_locale_to_lcid( const char *unix_name ) { if (!strcmpW( buffer, posixW ) || !strcmpW( buffer, cW )) return MAKELCID( MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT), SORT_DEFAULT ); - strcpyW( win_name, buffer ); + wcscpy( win_name, buffer ); } else { @@ -874,7 +874,7 @@ static LCID unix_locale_to_lcid( const char *unix_name ) /* rebuild a Windows name */ - strcpyW( win_name, buffer ); + wcscpy( win_name, buffer ); if (modifier) { if (!strcmpW( modifier, latinW )) strcatW( win_name, latnW ); @@ -885,7 +885,7 @@ static LCID unix_locale_to_lcid( const char *unix_name ) { p = win_name + strlenW(win_name); *p++ = '-'; - strcpyW( p, country ); + wcscpy( p, country ); } if (!RtlLocaleNameToLcid( win_name, &lcid, 0 )) return lcid; @@ -1672,7 +1672,7 @@ NTSTATUS WINAPI RtlLocaleNameToLcid( const WCHAR *name, LCID *lcid, ULONG flags goto found; } if (strlenW( name ) >= LOCALE_NAME_MAX_LENGTH) return STATUS_INVALID_PARAMETER_1; - strcpyW( lang, name ); + wcscpy( lang, name ); if ((p = strpbrkW( lang, sepW )) && *p == '-') { diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 32beee5e7f3..37128521dcc 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -302,6 +302,7 @@ int WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... ); #define towupper(c) NTDLL_towupper(c) #define wcslwr(s) NTDLL__wcslwr(s) #define wcsupr(s) NTDLL__wcsupr(s) +#define wcscpy(d,s) NTDLL_wcscpy(d,s) #define wcstoul(s,e,b) NTDLL_wcstoul(s,e,b) /* convert from straight ASCII to Unicode without depending on the current codepage */ diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c index 2f7b031d81d..5804f8f53f5 100644 --- a/dlls/ntdll/path.c +++ b/dlls/ntdll/path.c @@ -394,7 +394,7 @@ NTSTATUS WINAPI RtlDosPathNameToNtPathName_U_WithStatus(const WCHAR *dos_path, U return STATUS_NO_MEMORY; } - strcpyW(ntpath->Buffer, NTDosPrefixW); + wcscpy(ntpath->Buffer, NTDosPrefixW); switch (RtlDetermineDosPathNameType_U(ptr)) { case UNC_PATH: /* \\foo */ @@ -513,7 +513,7 @@ ULONG WINAPI RtlDosSearchPath_U(LPCWSTR paths, LPCWSTR search, LPCWSTR ext, memmove(name, paths, needed * sizeof(WCHAR)); /* append '\\' if none is present */ if (needed > 0 && name[needed - 1] != '\\') name[needed++] = '\\'; - strcpyW(&name[needed], search); + wcscpy(&name[needed], search); if (ext) strcatW(&name[needed], ext); if (RtlDoesFileExists_U(name)) { @@ -832,7 +832,7 @@ DWORD WINAPI RtlGetFullPathName_U(const WCHAR* name, ULONG size, WCHAR* buffer, DWORD sz = LOWORD(dosdev); /* in bytes */ if (8 + sz + 2 > size) return sz + 10; - strcpyW(buffer, DeviceRootW); + wcscpy(buffer, DeviceRootW); memmove(buffer + 4, name + offset, sz); buffer[4 + sz / sizeof(WCHAR)] = '\0'; /* file_part isn't set in this case */ diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 845e2e030d2..3ac66fb1c69 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -1192,7 +1192,7 @@ static NTSTATUS RTL_KeyHandleCreateObject(ULONG RelativeTo, PCWSTR Path, POBJECT if (str->Buffer == NULL) return STATUS_NO_MEMORY; - strcpyW(str->Buffer, base); + wcscpy(str->Buffer, base); strcatW(str->Buffer, Path); str->Length = len - sizeof(WCHAR); str->MaximumLength = len; diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c index b4ea0a4dba7..1e4d8054053 100644 --- a/dlls/ntdll/relay.c +++ b/dlls/ntdll/relay.c @@ -116,7 +116,7 @@ static const WCHAR **build_list( const WCHAR *buffer ) WCHAR *str = (WCHAR *)(ret + count + 1); WCHAR *q = str; - strcpyW( str, buffer ); + wcscpy( str, buffer ); count = 0; for (;;) { diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index c65983a300c..64853369a36 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -42,7 +42,6 @@ #include "winternl.h" #include "wine/debug.h" #include "wine/exception.h" -#include "wine/unicode.h" #include "ntdll_misc.h" #include "inaddr.h" #include "in6addr.h" @@ -1119,7 +1118,7 @@ NTSTATUS WINAPI RtlIpv4AddressToStringExW(const IN_ADDR *pin, USHORT port, LPWST if (*psize > needed) { *psize = needed + 1; - strcpyW(buffer, tmp_ip); + wcscpy(buffer, tmp_ip); return STATUS_SUCCESS; } diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c index 6774ce3b3c8..4e12353584a 100644 --- a/dlls/ntdll/sec.c +++ b/dlls/ntdll/sec.c @@ -38,7 +38,6 @@ #include "ntdll_misc.h" #include "wine/exception.h" #include "wine/library.h" -#include "wine/unicode.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(ntdll); diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c index fdd67d9d4a7..21b25df3f3b 100644 --- a/dlls/ntdll/time.c +++ b/dlls/ntdll/time.c @@ -684,7 +684,7 @@ static BOOL match_tz_name(const char* tz_name, if (reg_tzi->DaylightDate.wMonth) return TRUE; - strcpyW(key.key_name, reg_tzi->TimeZoneKeyName); + wcscpy(key.key_name, reg_tzi->TimeZoneKeyName); match = bsearch(&key, mapping, ARRAY_SIZE(mapping), sizeof(mapping[0]), compare_tz_key); if (!match) return TRUE; diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c index e5fb63e7782..8570a2fd510 100644 --- a/dlls/ntdll/version.c +++ b/dlls/ntdll/version.c @@ -504,7 +504,7 @@ void version_init(void) if ((p = strrchrW( appname, '/' ))) appname = p + 1; if ((p = strrchrW( appname, '\\' ))) appname = p + 1; - strcpyW( appversion, appdefaultsW ); + wcscpy( appversion, appdefaultsW ); strcatW( appversion, appname ); RtlInitUnicodeString( &nameW, appversion ); attr.RootDirectory = config_key; @@ -595,7 +595,7 @@ NTSTATUS WINAPI RtlGetVersion( RTL_OSVERSIONINFOEXW *info ) info->dwMinorVersion = current_version->dwMinorVersion; info->dwBuildNumber = current_version->dwBuildNumber; info->dwPlatformId = current_version->dwPlatformId; - strcpyW( info->szCSDVersion, current_version->szCSDVersion ); + wcscpy( info->szCSDVersion, current_version->szCSDVersion ); if(info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW)) { info->wServicePackMajor = current_version->wServicePackMajor;