ntdll: Use the standard C library names for the printf functions.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-06-30 12:04:42 +02:00
parent 8a169390c9
commit 4478ba258e
10 changed files with 47 additions and 49 deletions

View File

@ -1098,7 +1098,7 @@ static WCHAR *build_assembly_dir(struct assembly_identity* ai)
wcscat( ret, undW ); wcscat( ret, undW );
wcscat( ret, key ); wcscat( ret, key );
wcscat( ret, undW ); wcscat( ret, undW );
NTDLL_swprintf( ret + wcslen(ret), version_formatW, swprintf( ret + wcslen(ret), size - wcslen(ret), version_formatW,
ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); ai->version.major, ai->version.minor, ai->version.build, ai->version.revision );
wcscat( ret, undW ); wcscat( ret, undW );
wcscat( ret, lang ); wcscat( ret, lang );
@ -1135,7 +1135,7 @@ static WCHAR *build_assembly_id( const struct assembly_identity *ai )
WCHAR version[64], *ret; WCHAR version[64], *ret;
SIZE_T size = 0; SIZE_T size = 0;
NTDLL_swprintf( version, version_formatW, swprintf( version, ARRAY_SIZE(version), version_formatW,
ai->version.major, ai->version.minor, ai->version.build, ai->version.revision ); ai->version.major, ai->version.minor, ai->version.build, ai->version.revision );
if (ai->name) size += wcslen(ai->name) * sizeof(WCHAR); if (ai->name) size += wcslen(ai->name) * sizeof(WCHAR);
if (ai->arch) size += wcslen(archW) + wcslen(ai->arch) + 2; if (ai->arch) size += wcslen(archW) + wcslen(ai->arch) + 2;
@ -1981,7 +1981,7 @@ static int get_assembly_version(struct assembly *assembly, WCHAR *ret)
WCHAR buff[25]; WCHAR buff[25];
if (!ret) ret = buff; if (!ret) ret = buff;
return NTDLL_swprintf(ret, fmtW, ver->major, ver->minor, ver->build, ver->revision); return swprintf(ret, ARRAY_SIZE(buff), fmtW, ver->major, ver->minor, ver->build, ver->revision);
} }
static void parse_window_class_elem( xmlbuf_t *xmlbuf, struct dll_redirect *dll, static void parse_window_class_elem( xmlbuf_t *xmlbuf, struct dll_redirect *dll,
@ -3091,7 +3091,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 (!(status = get_module_filename( module, &name, sizeof(dotManifestW) + 10*sizeof(WCHAR) )))
{ {
if (resid != 1) NTDLL_swprintf( name.Buffer + wcslen(name.Buffer), fmtW, resid ); if (resid != 1) swprintf( name.Buffer + wcslen(name.Buffer), 10, fmtW, resid );
wcscat( name.Buffer, dotManifestW ); wcscat( name.Buffer, dotManifestW );
if (!RtlDosPathNameToNtPathName_U( name.Buffer, &nameW, NULL, NULL )) if (!RtlDosPathNameToNtPathName_U( name.Buffer, &nameW, NULL, NULL ))
status = STATUS_RESOURCE_DATA_NOT_FOUND; status = STATUS_RESOURCE_DATA_NOT_FOUND;
@ -3105,7 +3105,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl,
(wcslen(filename) + 10) * sizeof(WCHAR) + sizeof(dotManifestW) ))) (wcslen(filename) + 10) * sizeof(WCHAR) + sizeof(dotManifestW) )))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
wcscpy( buffer, filename ); wcscpy( buffer, filename );
if (resid != 1) NTDLL_swprintf( buffer + wcslen(buffer), fmtW, resid ); if (resid != 1) swprintf( buffer + wcslen(buffer), 10, fmtW, resid );
wcscat( buffer, dotManifestW ); wcscat( buffer, dotManifestW );
RtlInitUnicodeString( &nameW, buffer ); RtlInitUnicodeString( &nameW, buffer );
} }
@ -3131,17 +3131,14 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
UNICODE_STRING lookup_us; UNICODE_STRING lookup_us;
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
const WCHAR *lang = ai->language; const WCHAR *lang = ai->language;
unsigned int data_pos = 0, data_len; unsigned int data_pos = 0, data_len, len;
char buffer[8192]; char buffer[8192];
if (!lang || !wcsicmp( lang, neutralW )) lang = wildcardW; if (!lang || !wcsicmp( lang, neutralW )) lang = wildcardW;
if (!(lookup = RtlAllocateHeap( GetProcessHeap(), 0, len = wcslen(ai->arch) + wcslen(ai->name) + wcslen(ai->public_key) + wcslen(lang) + 20 + ARRAY_SIZE(lookup_fmtW);
(wcslen(ai->arch) + wcslen(ai->name) if (!(lookup = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
+ wcslen(ai->public_key) + wcslen(lang) + 20) * sizeof(WCHAR) swprintf( lookup, len, lookup_fmtW, ai->arch, ai->name, ai->public_key,
+ sizeof(lookup_fmtW) )))
return NULL;
NTDLL_swprintf( lookup, lookup_fmtW, ai->arch, ai->name, ai->public_key,
ai->version.major, ai->version.minor, lang ); ai->version.major, ai->version.minor, lang );
RtlInitUnicodeString( &lookup_us, lookup ); RtlInitUnicodeString( &lookup_us, lookup );

View File

@ -106,7 +106,7 @@ static ULONG integral_atom_name(WCHAR* buffer, ULONG len, RTL_ATOM atom)
WCHAR tmp[16]; WCHAR tmp[16];
int ret; int ret;
ret = NTDLL_swprintf( tmp, fmt, atom ); ret = swprintf( tmp, ARRAY_SIZE(tmp), fmt, atom );
if (!len) return ret * sizeof(WCHAR); if (!len) return ret * sizeof(WCHAR);
if (len <= ret) ret = len - 1; if (len <= ret) ret = len - 1;
memcpy( buffer, tmp, ret * sizeof(WCHAR) ); memcpy( buffer, tmp, ret * sizeof(WCHAR) );

View File

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

View File

@ -1455,7 +1455,7 @@
@ cdecl _memicmp(str str long) @ cdecl _memicmp(str str long)
@ varargs _snprintf(ptr long str) NTDLL__snprintf @ varargs _snprintf(ptr long str) NTDLL__snprintf
@ varargs _snprintf_s(ptr long long str) @ varargs _snprintf_s(ptr long long str)
@ varargs _snwprintf(ptr long wstr) NTDLL__snwprintf @ varargs _snwprintf(ptr long wstr)
@ varargs _snwprintf_s(ptr long long wstr) @ varargs _snwprintf_s(ptr long long wstr)
@ varargs _swprintf(ptr wstr) NTDLL_swprintf @ varargs _swprintf(ptr wstr) NTDLL_swprintf
@ cdecl _splitpath(str ptr ptr ptr ptr) @ cdecl _splitpath(str ptr ptr ptr ptr)
@ -1472,9 +1472,9 @@
@ cdecl _ultow(long ptr long) @ cdecl _ultow(long ptr long)
@ cdecl -norelay _vsnprintf(ptr long str ptr) @ cdecl -norelay _vsnprintf(ptr long str ptr)
@ cdecl _vsnprintf_s(ptr long str ptr) @ cdecl _vsnprintf_s(ptr long str ptr)
@ cdecl _vsnwprintf(ptr long wstr ptr) NTDLL__vsnwprintf @ cdecl _vsnwprintf(ptr long wstr ptr)
@ cdecl _vsnwprintf_s(ptr long long wstr ptr) @ cdecl _vsnwprintf_s(ptr long long wstr ptr)
@ cdecl _vswprintf(ptr wstr ptr) NTDLL__vswprintf @ cdecl _vswprintf(ptr wstr ptr)
@ cdecl _wcsicmp(wstr wstr) NTDLL__wcsicmp @ cdecl _wcsicmp(wstr wstr) NTDLL__wcsicmp
@ cdecl _wcslwr(wstr) NTDLL__wcslwr @ cdecl _wcslwr(wstr) NTDLL__wcslwr
@ cdecl _wcsnicmp(wstr wstr long) NTDLL__wcsnicmp @ cdecl _wcsnicmp(wstr wstr long) NTDLL__wcsnicmp
@ -1548,7 +1548,7 @@
@ cdecl towupper(long) NTDLL_towupper @ cdecl towupper(long) NTDLL_towupper
@ stdcall vDbgPrintEx(long long str ptr) @ stdcall vDbgPrintEx(long long str ptr)
@ stdcall vDbgPrintExWithPrefix(str long long str ptr) @ stdcall vDbgPrintExWithPrefix(str long long str ptr)
@ cdecl vsprintf(ptr str ptr) NTDLL_vsprintf @ cdecl vsprintf(ptr str ptr)
@ cdecl vsprintf_s(ptr long str ptr) @ cdecl vsprintf_s(ptr long str ptr)
@ cdecl vswprintf_s(ptr long wstr ptr) @ cdecl vswprintf_s(ptr long wstr ptr)
@ cdecl wcscat(wstr wstr) NTDLL_wcscat @ cdecl wcscat(wstr wstr) NTDLL_wcscat

View File

@ -181,7 +181,6 @@ LPWSTR __cdecl NTDLL_wcsstr( LPCWSTR str, LPCWSTR sub );
LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim ); LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim );
LONG __cdecl NTDLL_wcstol( LPCWSTR s, LPWSTR *end, INT base ); LONG __cdecl NTDLL_wcstol( LPCWSTR s, LPWSTR *end, INT base );
ULONG __cdecl NTDLL_wcstoul( 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 memchr(p,c,n) NTDLL_memchr(p,c,n) #define memchr(p,c,n) NTDLL_memchr(p,c,n)
#define strcat(d,s) NTDLL_strcat(d,s) #define strcat(d,s) NTDLL_strcat(d,s)

View File

@ -618,7 +618,7 @@ int CDECL _vsnprintf( char *str, size_t len, const char *format, __ms_va_list ar
/*********************************************************************** /***********************************************************************
* _vsnwprintf (NTDLL.@) * _vsnwprintf (NTDLL.@)
*/ */
int CDECL NTDLL__vsnwprintf( WCHAR *str, SIZE_T len, const WCHAR *format, __ms_va_list args ) int CDECL _vsnwprintf( WCHAR *str, size_t len, const WCHAR *format, __ms_va_list args )
{ {
pf_output out; pf_output out;
int r; int r;
@ -637,7 +637,7 @@ int CDECL NTDLL__vsnwprintf( WCHAR *str, SIZE_T len, const WCHAR *format, __ms_v
/********************************************************************* /*********************************************************************
* _snprintf (NTDLL.@) * _snprintf (NTDLL.@)
*/ */
int WINAPIV NTDLL__snprintf( char *str, SIZE_T len, const char *format, ... ) int WINAPIV NTDLL__snprintf( char *str, size_t len, const char *format, ... )
{ {
int ret; int ret;
__ms_va_list valist; __ms_va_list valist;
@ -652,13 +652,13 @@ int WINAPIV NTDLL__snprintf( char *str, SIZE_T len, const char *format, ... )
/*********************************************************************** /***********************************************************************
* _snwprintf (NTDLL.@) * _snwprintf (NTDLL.@)
*/ */
int WINAPIV NTDLL__snwprintf( WCHAR *str, SIZE_T len, const WCHAR *format, ... ) int WINAPIV _snwprintf( WCHAR *str, size_t len, const WCHAR *format, ... )
{ {
int ret; int ret;
__ms_va_list valist; __ms_va_list valist;
__ms_va_start(valist, format); __ms_va_start(valist, format);
ret = NTDLL__vsnwprintf( str, len, format, valist ); ret = _vsnwprintf( str, len, format, valist );
__ms_va_end(valist); __ms_va_end(valist);
return ret; return ret;
} }
@ -748,7 +748,7 @@ int WINAPIV _snwprintf_s( WCHAR *str, size_t size, size_t len, const WCHAR *form
/********************************************************************* /*********************************************************************
* vsprintf (NTDLL.@) * vsprintf (NTDLL.@)
*/ */
int CDECL NTDLL_vsprintf( char *str, const char *format, __ms_va_list args ) int CDECL vsprintf( char *str, const char *format, __ms_va_list args )
{ {
return _vsnprintf( str, size_max, format, args ); return _vsnprintf( str, size_max, format, args );
} }
@ -766,9 +766,9 @@ int CDECL vsprintf_s( char *str, size_t size, const char *format, __ms_va_list a
/********************************************************************* /*********************************************************************
* _vswprintf (NTDLL.@) * _vswprintf (NTDLL.@)
*/ */
int CDECL NTDLL__vswprintf( WCHAR *str, const WCHAR *format, __ms_va_list args ) int CDECL _vswprintf( WCHAR *str, const WCHAR *format, __ms_va_list args )
{ {
return NTDLL__vsnwprintf( str, size_max, format, args ); return _vsnwprintf( str, size_max, format, args );
} }
@ -820,7 +820,7 @@ int WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... )
__ms_va_list valist; __ms_va_list valist;
__ms_va_start(valist, format); __ms_va_start(valist, format);
ret = NTDLL__vsnwprintf( str, size_max, format, valist ); ret = _vsnwprintf( str, size_max, format, valist );
__ms_va_end(valist); __ms_va_end(valist);
return ret; return ret;
} }

View File

@ -204,6 +204,7 @@ NTSTATUS restart_process( RTL_USER_PROCESS_PARAMETERS *params, NTSTATUS status )
static const WCHAR comW[] = {'.','c','o','m',0}; static const WCHAR comW[] = {'.','c','o','m',0};
static const WCHAR pifW[] = {'.','p','i','f',0}; static const WCHAR pifW[] = {'.','p','i','f',0};
DWORD len;
WCHAR *p, *cmdline; WCHAR *p, *cmdline;
UNICODE_STRING pathW, cmdW; UNICODE_STRING pathW, cmdW;
@ -226,12 +227,11 @@ NTSTATUS restart_process( RTL_USER_PROCESS_PARAMETERS *params, NTSTATUS status )
case STATUS_INVALID_IMAGE_WIN_16: case STATUS_INVALID_IMAGE_WIN_16:
case STATUS_INVALID_IMAGE_NE_FORMAT: case STATUS_INVALID_IMAGE_NE_FORMAT:
case STATUS_INVALID_IMAGE_PROTECT: case STATUS_INVALID_IMAGE_PROTECT:
cmdline = RtlAllocateHeap( GetProcessHeap(), 0, len = (wcslen(system_dir) + wcslen(winevdm) + 16 + wcslen(params->ImagePathName.Buffer) +
(wcslen(system_dir) + wcslen(winevdm) + 16 + wcslen(params->CommandLine.Buffer));
wcslen(params->ImagePathName.Buffer) + if (!(cmdline = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
wcslen(params->CommandLine.Buffer)) * sizeof(WCHAR)); return STATUS_NO_MEMORY;
if (!cmdline) return STATUS_NO_MEMORY; swprintf( cmdline, len, 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 ); winevdm, params->ImagePathName.Buffer, params->CommandLine.Buffer );
RtlInitUnicodeString( &pathW, winevdm ); RtlInitUnicodeString( &pathW, winevdm );
RtlInitUnicodeString( &cmdW, cmdline ); RtlInitUnicodeString( &cmdW, cmdline );

View File

@ -1319,11 +1319,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); TRACE("(%p:0x%x, %d, %p, %p:%d)\n", pin, pin->S_un.S_addr, port, buffer, psize, *psize);
needed = NTDLL_swprintf(tmp_ip, fmt_ip, needed = swprintf(tmp_ip, ARRAY_SIZE(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_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); pin->S_un.S_un_b.s_b3, pin->S_un.S_un_b.s_b4);
if (port) needed += NTDLL_swprintf(tmp_ip + needed, fmt_port, ntohs(port)); if (port) needed += swprintf(tmp_ip + needed, ARRAY_SIZE(tmp_ip) - needed, fmt_port, ntohs(port));
if (*psize > needed) { if (*psize > needed) {
*psize = needed + 1; *psize = needed + 1;

View File

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

View File

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