ntdll: Avoid using sprintfW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Alexandre Julliard 2020-03-30 22:18:41 +02:00
parent 8f3d869d78
commit eb1b2e5486
10 changed files with 27 additions and 25 deletions

View File

@ -1104,7 +1104,7 @@ static WCHAR *build_assembly_dir(struct assembly_identity* ai)
strcatW( ret, undW );
strcatW( ret, key );
strcatW( ret, undW );
sprintfW( ret + strlenW(ret), version_formatW,
NTDLL_swprintf( ret + strlenW(ret), version_formatW,
ai->version.major, ai->version.minor, ai->version.build, ai->version.revision );
strcatW( ret, undW );
strcatW( ret, lang );
@ -1141,7 +1141,7 @@ static WCHAR *build_assembly_id( const struct assembly_identity *ai )
WCHAR version[64], *ret;
SIZE_T size = 0;
sprintfW( version, version_formatW,
NTDLL_swprintf( version, version_formatW,
ai->version.major, ai->version.minor, ai->version.build, ai->version.revision );
if (ai->name) size += strlenW(ai->name) * sizeof(WCHAR);
if (ai->arch) size += strlenW(archW) + strlenW(ai->arch) + 2;
@ -1951,7 +1951,7 @@ static int get_assembly_version(struct assembly *assembly, WCHAR *ret)
WCHAR buff[25];
if (!ret) ret = buff;
return sprintfW(ret, fmtW, ver->major, ver->minor, ver->build, ver->revision);
return NTDLL_swprintf(ret, fmtW, ver->major, ver->minor, ver->build, ver->revision);
}
static void parse_window_class_elem( xmlbuf_t *xmlbuf, struct dll_redirect *dll,
@ -3061,7 +3061,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl,
if (!(status = get_module_filename( module, &name, sizeof(dotManifestW) + 10*sizeof(WCHAR) )))
{
if (resid != 1) sprintfW( name.Buffer + strlenW(name.Buffer), fmtW, resid );
if (resid != 1) NTDLL_swprintf( name.Buffer + strlenW(name.Buffer), fmtW, resid );
strcatW( name.Buffer, dotManifestW );
if (!RtlDosPathNameToNtPathName_U( name.Buffer, &nameW, NULL, NULL ))
status = STATUS_RESOURCE_DATA_NOT_FOUND;
@ -3075,7 +3075,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl,
(strlenW(filename) + 10) * sizeof(WCHAR) + sizeof(dotManifestW) )))
return STATUS_NO_MEMORY;
strcpyW( buffer, filename );
if (resid != 1) sprintfW( buffer + strlenW(buffer), fmtW, resid );
if (resid != 1) NTDLL_swprintf( buffer + strlenW(buffer), fmtW, resid );
strcatW( buffer, dotManifestW );
RtlInitUnicodeString( &nameW, buffer );
}
@ -3111,7 +3111,7 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
+ strlenW(ai->public_key) + strlenW(lang) + 20) * sizeof(WCHAR)
+ sizeof(lookup_fmtW) )))
return NULL;
sprintfW( lookup, lookup_fmtW, ai->arch, ai->name, ai->public_key,
NTDLL_swprintf( lookup, lookup_fmtW, ai->arch, ai->name, ai->public_key,
ai->version.major, ai->version.minor, lang );
RtlInitUnicodeString( &lookup_us, lookup );

View File

@ -34,6 +34,7 @@
#include "wine/server.h"
#include "wine/unicode.h"
#include "ntdll_misc.h"
#include "wine/debug.h"
@ -109,7 +110,7 @@ static ULONG integral_atom_name(WCHAR* buffer, ULONG len, RTL_ATOM atom)
WCHAR tmp[16];
int ret;
ret = sprintfW( tmp, fmt, atom );
ret = NTDLL_swprintf( tmp, fmt, atom );
if (!len) return ret * sizeof(WCHAR);
if (len <= ret) ret = len - 1;
memcpy( buffer, tmp, ret * sizeof(WCHAR) );

View File

@ -399,10 +399,10 @@ static void set_wow64_environment( WCHAR **env )
set_wine_path_variable( env, wineconfigdirW, wine_get_config_dir() );
for (i = 0; (path = wine_dll_enum_load_path( i )); i++)
{
sprintfW( buf, winedlldirW, i );
NTDLL_swprintf( buf, winedlldirW, i );
set_wine_path_variable( env, buf, path );
}
sprintfW( buf, winedlldirW, i );
NTDLL_swprintf( buf, winedlldirW, i );
set_wine_path_variable( env, buf, NULL );
/* set the PROCESSOR_ARCHITECTURE variable */

View File

@ -590,16 +590,16 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
break;
case NLS_SECTION_CASEMAP:
if (id) return STATUS_UNSUCCESSFUL;
sprintfW( buffer, keyfmtW, langW );
sprintfW( value, langfmtW, LANGIDFROMLCID(system_lcid) );
NTDLL_swprintf( buffer, keyfmtW, langW );
NTDLL_swprintf( value, langfmtW, LANGIDFROMLCID(system_lcid) );
break;
case NLS_SECTION_CODEPAGE:
sprintfW( buffer, keyfmtW, cpW );
sprintfW( value, cpfmtW, id );
NTDLL_swprintf( buffer, keyfmtW, cpW );
NTDLL_swprintf( value, cpfmtW, id );
break;
case NLS_SECTION_NORMALIZE:
sprintfW( buffer, keyfmtW, normW );
sprintfW( value, normfmtW, id );
NTDLL_swprintf( buffer, keyfmtW, normW );
NTDLL_swprintf( value, normfmtW, id );
break;
default:
return STATUS_INVALID_PARAMETER_1;
@ -635,7 +635,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
name = intlW;
break;
case NLS_SECTION_CODEPAGE:
sprintfW( buffer, cpdefaultW, id );
NTDLL_swprintf( buffer, cpdefaultW, id );
name = buffer;
break;
case NLS_SECTION_NORMALIZE:
@ -657,7 +657,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
valueW.MaximumLength = (strlenW(name) + strlenW(dir) + 5) * sizeof(WCHAR);
if (!(valueW.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, valueW.MaximumLength )))
return STATUS_NO_MEMORY;
valueW.Length = sprintfW( valueW.Buffer, pathfmtW, dir, name ) * sizeof(WCHAR);
valueW.Length = NTDLL_swprintf( valueW.Buffer, pathfmtW, dir, name ) * sizeof(WCHAR);
InitializeObjectAttributes( &attr, &valueW, 0, 0, NULL );
status = NtOpenFile( file, GENERIC_READ, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT );
if (!status) TRACE( "found %s\n", debugstr_w( valueW.Buffer ));

View File

@ -295,6 +295,7 @@ LPWSTR __cdecl NTDLL_wcsstr( LPCWSTR str, LPCWSTR sub );
LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim );
LONG __cdecl NTDLL_wcstol( LPCWSTR s, LPWSTR *end, INT base );
ULONG __cdecl NTDLL_wcstoul( LPCWSTR s, LPWSTR *end, INT base );
int WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... );
#define wcsicmp(s1,s2) NTDLL__wcsicmp(s1,s2)
#define wcsnicmp(s1,s2,n) NTDLL__wcsnicmp(s1,s2,n)

View File

@ -1605,7 +1605,7 @@ NTSTATUS restart_process( RTL_USER_PROCESS_PARAMETERS *params, NTSTATUS status )
strlenW(params->ImagePathName.Buffer) +
strlenW(params->CommandLine.Buffer)) * sizeof(WCHAR));
if (!cmdline) return STATUS_NO_MEMORY;
sprintfW( cmdline, argsW, (is_win64 || is_wow64) ? syswow64_dir : system_dir,
NTDLL_swprintf( cmdline, argsW, (is_win64 || is_wow64) ? syswow64_dir : system_dir,
winevdm, params->ImagePathName.Buffer, params->CommandLine.Buffer );
RtlInitUnicodeString( &strW, cmdline );
memset( &pe_info, 0, sizeof(pe_info) );

View File

@ -1111,11 +1111,11 @@ NTSTATUS WINAPI RtlIpv4AddressToStringExW(const IN_ADDR *pin, USHORT port, LPWST
TRACE("(%p:0x%x, %d, %p, %p:%d)\n", pin, pin->S_un.S_addr, port, buffer, psize, *psize);
needed = sprintfW(tmp_ip, fmt_ip,
needed = NTDLL_swprintf(tmp_ip, fmt_ip,
pin->S_un.S_un_b.s_b1, pin->S_un.S_un_b.s_b2,
pin->S_un.S_un_b.s_b3, pin->S_un.S_un_b.s_b4);
if (port) needed += sprintfW(tmp_ip + needed, fmt_port, ntohs(port));
if (port) needed += NTDLL_swprintf(tmp_ip + needed, fmt_port, ntohs(port));
if (*psize > needed) {
*psize = needed + 1;

View File

@ -1702,7 +1702,7 @@ NTSTATUS WINAPI RtlStringFromGUID(const GUID* guid, UNICODE_STRING *str)
str->Length = str->MaximumLength = 0;
return STATUS_NO_MEMORY;
}
sprintfW(str->Buffer, szFormat, guid->Data1, guid->Data2, guid->Data3,
NTDLL_swprintf(str->Buffer, szFormat, guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);

View File

@ -1828,13 +1828,13 @@ NTSTATUS WINAPI RtlConvertSidToUnicodeString(
DWORD i, len;
*p++ = 'S';
p += sprintfW( p, formatW, sid->Revision );
p += sprintfW( p, formatW, MAKELONG( MAKEWORD( sid->IdentifierAuthority.Value[5],
p += NTDLL_swprintf( p, formatW, sid->Revision );
p += NTDLL_swprintf( p, formatW, MAKELONG( MAKEWORD( sid->IdentifierAuthority.Value[5],
sid->IdentifierAuthority.Value[4] ),
MAKEWORD( sid->IdentifierAuthority.Value[3],
sid->IdentifierAuthority.Value[2] )));
for (i = 0; i < sid->SubAuthorityCount; i++)
p += sprintfW( p, formatW, sid->SubAuthority[i] );
p += NTDLL_swprintf( p, formatW, sid->SubAuthority[i] );
len = (p + 1 - buffer) * sizeof(WCHAR);

View File

@ -729,7 +729,7 @@ static void find_reg_tz_info(RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi, const char*
UNICODE_STRING nameW, nameDynamicW;
WCHAR buf[128], yearW[16];
sprintfW(yearW, fmtW, year);
NTDLL_swprintf(yearW, fmtW, year);
attrDynamic.Length = sizeof(attrDynamic);
attrDynamic.RootDirectory = 0; /* will be replaced later */