mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-30 04:48:36 +00:00
win32u: Replace sprintf with snprintf to avoid deprecation warnings on macOS.
This commit is contained in:
parent
3992a76ee9
commit
996070283c
|
@ -2967,10 +2967,10 @@ LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
|
|||
|
||||
if (NtUserGetAncestor( hwnd, GA_PARENT )) return FALSE; /* refuse to create non-desktop window */
|
||||
|
||||
sprintf( buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
(unsigned int)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] );
|
||||
snprintf( buffer, sizeof(buffer), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
(unsigned int)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] );
|
||||
NtAddAtom( bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), &atom );
|
||||
NtUserSetProp( hwnd, wine_display_device_guidW, ULongToHandle( atom ) );
|
||||
}
|
||||
|
|
|
@ -1373,7 +1373,7 @@ static void add_face_to_cache( struct gdi_font_face *face )
|
|||
WCHAR nameW[10];
|
||||
char name[10];
|
||||
|
||||
sprintf( name, "%d", face->size.y_ppem );
|
||||
snprintf( name, sizeof(name), "%d", face->size.y_ppem );
|
||||
hkey_face = reg_create_key( hkey_family, nameW,
|
||||
asciiz_to_unicode( nameW, name ) - sizeof(WCHAR),
|
||||
REG_OPTION_VOLATILE, NULL );
|
||||
|
@ -1411,7 +1411,7 @@ static void remove_face_from_cache( struct gdi_font_face *face )
|
|||
{
|
||||
WCHAR nameW[10];
|
||||
char name[10];
|
||||
sprintf( name, "%d", face->size.y_ppem );
|
||||
snprintf( name, sizeof(name), "%d", face->size.y_ppem );
|
||||
if ((hkey = reg_open_key( hkey_family, nameW,
|
||||
asciiz_to_unicode( nameW, name ) - sizeof(WCHAR) )))
|
||||
{
|
||||
|
@ -3143,7 +3143,7 @@ static void update_codepage( UINT screen_dpi )
|
|||
RtlInitCodePageTable( NtCurrentTeb()->Peb->OemCodePageData, &oem_cp );
|
||||
else
|
||||
oem_cp = utf8_cp;
|
||||
sprintf( cpbuf, "%u,%u", ansi_cp.CodePage, oem_cp.CodePage );
|
||||
snprintf( cpbuf, sizeof(cpbuf), "%u,%u", ansi_cp.CodePage, oem_cp.CodePage );
|
||||
asciiz_to_unicode( cpbufW, cpbuf );
|
||||
|
||||
if (query_reg_ascii_value( wine_fonts_key, "Codepages", info, sizeof(value_buffer) ))
|
||||
|
@ -6767,11 +6767,11 @@ static HKEY open_hkcu(void)
|
|||
return 0;
|
||||
|
||||
sid = ((TOKEN_USER *)sid_data)->User.Sid;
|
||||
len = sprintf( buffer, "\\Registry\\User\\S-%u-%u", (int)sid->Revision,
|
||||
len = snprintf( buffer, sizeof(buffer), "\\Registry\\User\\S-%u-%u", (int)sid->Revision,
|
||||
(int)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++)
|
||||
len += sprintf( buffer + len, "-%u", (int)sid->SubAuthority[i] );
|
||||
len += snprintf( buffer + len, sizeof(buffer) - len, "-%u", (int)sid->SubAuthority[i] );
|
||||
ascii_to_unicode( bufferW, buffer, len + 1 );
|
||||
|
||||
return reg_open_key( NULL, bufferW, len * sizeof(WCHAR) );
|
||||
|
|
|
@ -487,7 +487,7 @@ static char **expand_mac_font(const char *path)
|
|||
{
|
||||
int fd;
|
||||
|
||||
sprintf(output, "%s/%s_%04x.ttf", out_dir, filename, font_id);
|
||||
snprintf(output, output_len, "%s/%s_%04x.ttf", out_dir, filename, font_id);
|
||||
|
||||
fd = open(output, O_CREAT | O_EXCL | O_WRONLY, 0600);
|
||||
if(fd != -1 || errno == EEXIST)
|
||||
|
@ -1456,7 +1456,7 @@ static BOOL ReadFontDir(const char *dirname, BOOL external_fonts)
|
|||
|
||||
TRACE("Found %s in %s\n", debugstr_a(dent->d_name), debugstr_a(dirname));
|
||||
|
||||
sprintf(path, "%s/%s", dirname, dent->d_name);
|
||||
snprintf(path, sizeof(path), "%s/%s", dirname, dent->d_name);
|
||||
|
||||
if(stat(path, &statbuf) == -1)
|
||||
{
|
||||
|
|
|
@ -1341,7 +1341,7 @@ BOOL WINAPI NtUserGetKeyboardLayoutName( WCHAR *name )
|
|||
|
||||
if (info->kbd_layout_id)
|
||||
{
|
||||
sprintf( buffer, "%08X", info->kbd_layout_id );
|
||||
snprintf( buffer, sizeof(buffer), "%08X", info->kbd_layout_id );
|
||||
asciiz_to_unicode( name, buffer );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1349,7 +1349,7 @@ BOOL WINAPI NtUserGetKeyboardLayoutName( WCHAR *name )
|
|||
layout = NtUserGetKeyboardLayout( 0 );
|
||||
id = HandleToUlong( layout );
|
||||
if (HIWORD( id ) == LOWORD( id )) id = LOWORD( id );
|
||||
sprintf( buffer, "%08X", id );
|
||||
snprintf( buffer, sizeof(buffer), "%08X", id );
|
||||
asciiz_to_unicode( name, buffer );
|
||||
|
||||
if ((hkey = reg_open_key( NULL, keyboard_layouts_keyW, sizeof(keyboard_layouts_keyW) )))
|
||||
|
|
|
@ -232,7 +232,7 @@ BOOL WINAPI NtUserDestroyAcceleratorTable( HACCEL handle )
|
|||
|
||||
#define MENUFLAG(bit,text) \
|
||||
do { \
|
||||
if (flags & (bit)) { flags &= ~(bit); strcat(buf, (text)); } \
|
||||
if (flags & (bit)) { flags &= ~(bit); len += snprintf(buf + len, sizeof(buf) - len, (text)); } \
|
||||
} while (0)
|
||||
|
||||
static const char *debugstr_menuitem( const struct menu_item *item )
|
||||
|
@ -243,16 +243,17 @@ static const char *debugstr_menuitem( const struct menu_item *item )
|
|||
"HBMMENU_POPUP_RESTORE", "HBMMENU_POPUP_MAXIMIZE", "HBMMENU_POPUP_MINIMIZE" };
|
||||
char buf[256];
|
||||
UINT flags;
|
||||
int len;
|
||||
|
||||
if (!item) return "NULL";
|
||||
|
||||
sprintf( buf, "{ ID=0x%lx", (long)item->wID );
|
||||
if (item->hSubMenu) sprintf( buf + strlen(buf), ", Sub=%p", item->hSubMenu );
|
||||
len = snprintf( buf, sizeof(buf), "{ ID=0x%lx", (long)item->wID );
|
||||
if (item->hSubMenu) len += snprintf( buf + len, sizeof(buf) - len, ", Sub=%p", item->hSubMenu );
|
||||
|
||||
flags = item->fType;
|
||||
if (flags)
|
||||
{
|
||||
strcat( buf, ", fType=" );
|
||||
len += snprintf( buf + len, sizeof(buf) - len, ", fType=" );
|
||||
MENUFLAG( MFT_SEPARATOR, "sep" );
|
||||
MENUFLAG( MFT_OWNERDRAW, "own" );
|
||||
MENUFLAG( MFT_BITMAP, "bit" );
|
||||
|
@ -263,13 +264,13 @@ static const char *debugstr_menuitem( const struct menu_item *item )
|
|||
MENUFLAG( MFT_RIGHTORDER, "rorder" );
|
||||
MENUFLAG( MF_SYSMENU, "sys" );
|
||||
MENUFLAG( MFT_RIGHTJUSTIFY, "right" ); /* same as MF_HELP */
|
||||
if (flags) sprintf( buf + strlen(buf), "+0x%x", flags );
|
||||
if (flags) len += snprintf( buf + len, sizeof(buf) - len, "+0x%x", flags );
|
||||
}
|
||||
|
||||
flags = item->fState;
|
||||
if (flags)
|
||||
{
|
||||
strcat( buf, ", State=" );
|
||||
len += snprintf( buf + len, sizeof(buf) - len, ", State=" );
|
||||
MENUFLAG( MFS_GRAYED, "grey" );
|
||||
MENUFLAG( MFS_DEFAULT, "default" );
|
||||
MENUFLAG( MFS_DISABLED, "dis" );
|
||||
|
@ -277,20 +278,20 @@ static const char *debugstr_menuitem( const struct menu_item *item )
|
|||
MENUFLAG( MFS_HILITE, "hi" );
|
||||
MENUFLAG( MF_USECHECKBITMAPS, "usebit" );
|
||||
MENUFLAG( MF_MOUSESELECT, "mouse" );
|
||||
if (flags) sprintf( buf + strlen(buf), "+0x%x", flags );
|
||||
if (flags) len += snprintf( buf + len, sizeof(buf) - len, "+0x%x", flags );
|
||||
}
|
||||
|
||||
if (item->hCheckBit) sprintf( buf + strlen(buf), ", Chk=%p", item->hCheckBit );
|
||||
if (item->hUnCheckBit) sprintf( buf + strlen(buf), ", Unc=%p", item->hUnCheckBit );
|
||||
if (item->text) sprintf( buf + strlen(buf), ", Text=%s", debugstr_w(item->text) );
|
||||
if (item->dwItemData) sprintf( buf + strlen(buf), ", ItemData=0x%08lx", item->dwItemData );
|
||||
if (item->hCheckBit) len += snprintf( buf + len, sizeof(buf) - len, ", Chk=%p", item->hCheckBit );
|
||||
if (item->hUnCheckBit) len += snprintf( buf + len, sizeof(buf) - len, ", Unc=%p", item->hUnCheckBit );
|
||||
if (item->text) len += snprintf( buf + len, sizeof(buf) - len, ", Text=%s", debugstr_w(item->text) );
|
||||
if (item->dwItemData) len += snprintf( buf + len, sizeof(buf) - len, ", ItemData=0x%08lx", item->dwItemData );
|
||||
|
||||
if (item->hbmpItem)
|
||||
{
|
||||
if (IS_MAGIC_BITMAP( item->hbmpItem ))
|
||||
sprintf( buf + strlen(buf), ", hbitmap=%s", hbmmenus[(INT_PTR)item->hbmpItem + 1] );
|
||||
len += snprintf( buf + len, sizeof(buf) - len, ", hbitmap=%s", hbmmenus[(INT_PTR)item->hbmpItem + 1] );
|
||||
else
|
||||
sprintf( buf + strlen(buf), ", hbitmap=%p", item->hbmpItem );
|
||||
len += snprintf( buf + len, sizeof(buf) - len, ", hbitmap=%p", item->hbmpItem );
|
||||
}
|
||||
return wine_dbg_sprintf( "%s }", buf );
|
||||
}
|
||||
|
|
|
@ -2166,9 +2166,9 @@ static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e )
|
|||
}
|
||||
}
|
||||
if (sp_e->msgnum >= WM_USER && sp_e->msgnum <= WM_APP)
|
||||
sprintf( sp_e->msg_name, "WM_USER+%d", sp_e->msgnum - WM_USER );
|
||||
snprintf( sp_e->msg_name, sizeof(sp_e->msg_name), "WM_USER+%d", sp_e->msgnum - WM_USER );
|
||||
else
|
||||
sprintf( sp_e->msg_name, "%04x", sp_e->msgnum );
|
||||
snprintf( sp_e->msg_name, sizeof(sp_e->msg_name), "%04x", sp_e->msgnum );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2623,7 +2623,7 @@ void spy_enter_message( INT iFlag, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||
DWORD tid = get_window_thread( hWnd, NULL );
|
||||
|
||||
if (tid == GetCurrentThreadId()) strcpy( taskName, "self" );
|
||||
else sprintf( taskName, "tid %04x", (int)GetCurrentThreadId() );
|
||||
else snprintf( taskName, sizeof(taskName), "tid %04x", (int)GetCurrentThreadId() );
|
||||
|
||||
TRACE("%*s(%p) %-16s [%04x] %s sent from %s wp=%08lx lp=%08lx\n",
|
||||
indent, "", hWnd, debugstr_w(sp_e.wnd_name), msg,
|
||||
|
|
|
@ -388,7 +388,7 @@ static void get_monitor_info_from_edid( struct edid_monitor_info *info, const un
|
|||
w = edid[10] | (edid[11] << 8); /* Product code, little endian. */
|
||||
info->manufacturer = *(unsigned short *)(edid + 8);
|
||||
info->product_code = w;
|
||||
sprintf( info->monitor_id_string + 3, "%04X", w );
|
||||
snprintf( info->monitor_id_string + 3, sizeof(info->monitor_id_string) - 3, "%04X", w );
|
||||
info->flags = MONITOR_INFO_HAS_MONITOR_ID;
|
||||
TRACE( "Monitor id %s.\n", info->monitor_id_string );
|
||||
|
||||
|
@ -421,7 +421,7 @@ static BOOL write_source_mode( HKEY hkey, UINT index, const DEVMODEW *mode )
|
|||
WCHAR bufferW[MAX_PATH] = {0};
|
||||
char buffer[MAX_PATH];
|
||||
|
||||
sprintf( buffer, "Modes\\%08X", index );
|
||||
snprintf( buffer, sizeof(buffer), "Modes\\%08X", index );
|
||||
asciiz_to_unicode( bufferW, buffer );
|
||||
return set_reg_value( hkey, bufferW, REG_BINARY, &mode->dmFields, sizeof(*mode) - offsetof(DEVMODEW, dmFields) );
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ static BOOL read_source_mode( HKEY hkey, UINT index, DEVMODEW *mode )
|
|||
KEY_VALUE_PARTIAL_INFORMATION *value = (void *)value_buf;
|
||||
char buffer[MAX_PATH];
|
||||
|
||||
sprintf( buffer, "Modes\\%08X", index );
|
||||
snprintf( buffer, sizeof(buffer), "Modes\\%08X", index );
|
||||
if (!query_reg_ascii_value( hkey, buffer, value, sizeof(value_buf) )) return FALSE;
|
||||
|
||||
memcpy( &mode->dmFields, value->Data, sizeof(*mode) - offsetof(DEVMODEW, dmFields) );
|
||||
|
@ -486,7 +486,7 @@ static BOOL source_get_current_settings( const struct source *source, DEVMODEW *
|
|||
HKEY hkey;
|
||||
BOOL ret;
|
||||
|
||||
sprintf( device_name, "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
snprintf( device_name, sizeof(device_name), "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
asciiz_to_unicode( device_nameW, device_name );
|
||||
|
||||
/* use the default implementation in virtual desktop mode */
|
||||
|
@ -616,7 +616,7 @@ static BOOL reade_source_from_registry( unsigned int index, struct source *sourc
|
|||
return FALSE;
|
||||
|
||||
/* Find source */
|
||||
sprintf( buffer, "\\Device\\Video%d", index );
|
||||
snprintf( buffer, sizeof(buffer), "\\Device\\Video%d", index );
|
||||
size = query_reg_ascii_value( video_key, buffer, value, sizeof(buffer) );
|
||||
if (!size || value->Type != REG_SZ) return FALSE;
|
||||
|
||||
|
@ -716,7 +716,7 @@ static BOOL read_source_monitor_path( HKEY hkey, UINT index, char *path )
|
|||
DWORD size;
|
||||
UINT i;
|
||||
|
||||
sprintf( buffer, "MonitorID%u", index );
|
||||
snprintf( buffer, sizeof(buffer), "MonitorID%u", index );
|
||||
size = query_reg_ascii_value( hkey, buffer, value, sizeof(buffer) );
|
||||
if (!size || value->Type != REG_SZ) return FALSE;
|
||||
|
||||
|
@ -760,7 +760,7 @@ static void prepare_devices(void)
|
|||
|
||||
/* delete monitors */
|
||||
reg_empty_key( enum_key, "DISPLAY" );
|
||||
sprintf( buffer, "Class\\%s", guid_devclass_monitorA );
|
||||
snprintf( buffer, sizeof(buffer), "Class\\%s", guid_devclass_monitorA );
|
||||
hkey = reg_create_ascii_key( control_key, buffer, 0, NULL );
|
||||
reg_empty_key( hkey, NULL );
|
||||
set_reg_ascii_value( hkey, "Class", "Monitor" );
|
||||
|
@ -770,7 +770,7 @@ static void prepare_devices(void)
|
|||
reg_empty_key( video_key, NULL );
|
||||
|
||||
/* clean GPUs */
|
||||
sprintf( buffer, "Class\\%s", guid_devclass_displayA );
|
||||
snprintf( buffer, sizeof(buffer), "Class\\%s", guid_devclass_displayA );
|
||||
hkey = reg_create_ascii_key( control_key, buffer, 0, NULL );
|
||||
reg_empty_key( hkey, NULL );
|
||||
set_reg_ascii_value( hkey, "Class", "Display" );
|
||||
|
@ -907,7 +907,7 @@ static unsigned int format_date( WCHAR *bufferW, LONGLONG time )
|
|||
}
|
||||
day = yearday - (1959 * months) / 64 ;
|
||||
|
||||
sprintf( buffer, "%u-%u-%u", month, day, year );
|
||||
snprintf( buffer, sizeof(buffer), "%u-%u-%u", month, day, year );
|
||||
return asciiz_to_unicode( bufferW, buffer );
|
||||
}
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p
|
|||
|
||||
set_reg_ascii_value( hkey, "Class", "Display" );
|
||||
set_reg_ascii_value( hkey, "ClassGUID", guid_devclass_displayA );
|
||||
sprintf( buffer, "%s\\%04X", guid_devclass_displayA, gpu->index );
|
||||
snprintf( buffer, sizeof(buffer), "%s\\%04X", guid_devclass_displayA, gpu->index );
|
||||
set_reg_ascii_value( hkey, "Driver", buffer );
|
||||
|
||||
strcpy( buffer, gpu->path );
|
||||
|
@ -1117,7 +1117,7 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p
|
|||
NtClose( hkey );
|
||||
|
||||
|
||||
sprintf( buffer, "Class\\%s\\%04X", guid_devclass_displayA, gpu->index );
|
||||
snprintf( buffer, sizeof(buffer), "Class\\%s\\%04X", guid_devclass_displayA, gpu->index );
|
||||
if (!(hkey = reg_create_ascii_key( control_key, buffer, 0, NULL ))) return FALSE;
|
||||
|
||||
NtQuerySystemTime( &ft );
|
||||
|
@ -1146,19 +1146,19 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p
|
|||
{
|
||||
/* Intel */
|
||||
case 0x8086:
|
||||
sprintf( buffer, "31.0.101.4576" );
|
||||
strcpy( buffer, "31.0.101.4576" );
|
||||
break;
|
||||
/* AMD */
|
||||
case 0x1002:
|
||||
sprintf( buffer, "31.0.14051.5006" );
|
||||
strcpy( buffer, "31.0.14051.5006" );
|
||||
break;
|
||||
/* Nvidia */
|
||||
case 0x10de:
|
||||
sprintf( buffer, "31.0.15.3625" );
|
||||
strcpy( buffer, "31.0.15.3625" );
|
||||
break;
|
||||
/* Default value for any other vendor. */
|
||||
default:
|
||||
sprintf( buffer, "31.0.10.1000" );
|
||||
strcpy( buffer, "31.0.10.1000" );
|
||||
break;
|
||||
}
|
||||
set_reg_ascii_value( hkey, "DriverVersion", buffer );
|
||||
|
@ -1206,8 +1206,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
|
|||
lstrcpyW( ctx->gpu.name, gpu->name );
|
||||
ctx->gpu.vulkan_uuid = gpu->vulkan_uuid;
|
||||
|
||||
sprintf( ctx->gpu.path, "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\%08X",
|
||||
gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, ctx->gpu.index );
|
||||
snprintf( ctx->gpu.path, sizeof(ctx->gpu.path), "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\%08X",
|
||||
gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, ctx->gpu.index );
|
||||
if (!(hkey = reg_create_ascii_key( enum_key, ctx->gpu.path, 0, NULL ))) return;
|
||||
|
||||
if ((subkey = reg_create_ascii_key( hkey, "Device Parameters", 0, NULL )))
|
||||
|
@ -1216,9 +1216,9 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
|
|||
{
|
||||
GUID guid;
|
||||
uuid_create( &guid );
|
||||
sprintf( ctx->gpu.guid, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||
(unsigned int)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] );
|
||||
snprintf( ctx->gpu.guid, sizeof(ctx->gpu.guid), "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||
(unsigned int)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] );
|
||||
TRACE( "created guid %s\n", debugstr_a(ctx->gpu.guid) );
|
||||
}
|
||||
else
|
||||
|
@ -1261,18 +1261,18 @@ static BOOL write_source_to_registry( const struct source *source, HKEY *source_
|
|||
WCHAR bufferW[MAX_PATH];
|
||||
HKEY hkey;
|
||||
|
||||
sprintf( buffer, "%s\\Video\\%s\\%04x", control_keyA, gpu->guid, source_index );
|
||||
snprintf( buffer, sizeof(buffer), "%s\\Video\\%s\\%04x", control_keyA, gpu->guid, source_index );
|
||||
len = asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR);
|
||||
|
||||
hkey = reg_create_ascii_key( NULL, buffer, REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, NULL );
|
||||
if (!hkey) hkey = reg_create_ascii_key( NULL, buffer, REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL );
|
||||
|
||||
sprintf( name, "\\Device\\Video%u", source->id );
|
||||
snprintf( name, sizeof(name), "\\Device\\Video%u", source->id );
|
||||
set_reg_ascii_value( video_key, name, buffer );
|
||||
|
||||
if (!hkey) return FALSE;
|
||||
|
||||
sprintf( buffer, "%s\\Class\\%s\\%04X", control_keyA, guid_devclass_displayA, gpu->index );
|
||||
snprintf( buffer, sizeof(buffer), "%s\\Class\\%s\\%04X", control_keyA, guid_devclass_displayA, gpu->index );
|
||||
len = asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR);
|
||||
set_reg_value( hkey, symbolic_link_valueW, REG_LINK, bufferW, len );
|
||||
NtClose( hkey );
|
||||
|
@ -1283,7 +1283,7 @@ static BOOL write_source_to_registry( const struct source *source, HKEY *source_
|
|||
set_reg_value( *source_key, state_flagsW, REG_DWORD, &source->state_flags,
|
||||
sizeof(source->state_flags) );
|
||||
|
||||
sprintf( buffer, "System\\CurrentControlSet\\Control\\Video\\%s\\%04x", gpu->guid, source_index );
|
||||
snprintf( buffer, sizeof(buffer), "System\\CurrentControlSet\\Control\\Video\\%s\\%04x", gpu->guid, source_index );
|
||||
hkey = reg_create_ascii_key( config_key, buffer, REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, NULL );
|
||||
if (!hkey) hkey = reg_create_ascii_key( config_key, buffer, REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL );
|
||||
|
||||
|
@ -1312,8 +1312,8 @@ static void add_source( const char *name, UINT state_flags, void *param )
|
|||
ctx->source.state_flags = state_flags;
|
||||
|
||||
/* Wine specific config key where source settings will be held, symlinked with the logically indexed config key */
|
||||
sprintf( ctx->source.path, "%s\\%s\\Video\\%s\\Sources\\%s", config_keyA,
|
||||
control_keyA + strlen( "\\Registry\\Machine" ), ctx->gpu.guid, name );
|
||||
snprintf( ctx->source.path, sizeof(ctx->source.path), "%s\\%s\\Video\\%s\\Sources\\%s", config_keyA,
|
||||
control_keyA + strlen( "\\Registry\\Machine" ), ctx->gpu.guid, name );
|
||||
|
||||
if (!write_source_to_registry( &ctx->source, &ctx->source_key ))
|
||||
WARN( "Failed to write source to registry\n" );
|
||||
|
@ -1336,11 +1336,11 @@ static BOOL write_monitor_to_registry( struct monitor *monitor, const BYTE *edid
|
|||
set_reg_ascii_value( hkey, "DeviceDesc", "Generic Non-PnP Monitor" );
|
||||
|
||||
set_reg_ascii_value( hkey, "Class", "Monitor" );
|
||||
sprintf( buffer, "%s\\%04X", guid_devclass_monitorA, monitor->output_id );
|
||||
snprintf( buffer, sizeof(buffer), "%s\\%04X", guid_devclass_monitorA, monitor->output_id );
|
||||
set_reg_ascii_value( hkey, "Driver", buffer );
|
||||
set_reg_ascii_value( hkey, "ClassGUID", guid_devclass_monitorA );
|
||||
|
||||
sprintf( buffer, "MONITOR\\%s", monitor->path + 8 );
|
||||
snprintf( buffer, sizeof(buffer), "MONITOR\\%s", monitor->path + 8 );
|
||||
if ((tmp = strrchr( buffer, '\\' ))) *tmp = 0;
|
||||
len = asciiz_to_unicode( bufferW, buffer );
|
||||
bufferW[len / sizeof(WCHAR)] = 0;
|
||||
|
@ -1394,7 +1394,7 @@ static BOOL write_monitor_to_registry( struct monitor *monitor, const BYTE *edid
|
|||
NtClose( hkey );
|
||||
|
||||
|
||||
sprintf( buffer, "Class\\%s\\%04X", guid_devclass_monitorA, monitor->output_id );
|
||||
snprintf( buffer, sizeof(buffer), "Class\\%s\\%04X", guid_devclass_monitorA, monitor->output_id );
|
||||
if (!(hkey = reg_create_ascii_key( control_key, buffer, 0, NULL ))) return FALSE;
|
||||
NtClose( hkey );
|
||||
|
||||
|
@ -1424,8 +1424,8 @@ static void add_monitor( const struct gdi_monitor *gdi_monitor, void *param )
|
|||
else
|
||||
strcpy( monitor_id_string, "Default_Monitor" );
|
||||
|
||||
sprintf( buffer, "MonitorID%u", monitor.id );
|
||||
sprintf( monitor.path, "DISPLAY\\%s\\%04X&%04X", monitor_id_string, ctx->source.id, monitor.id );
|
||||
snprintf( buffer, sizeof(buffer), "MonitorID%u", monitor.id );
|
||||
snprintf( monitor.path, sizeof(monitor.path), "DISPLAY\\%s\\%04X&%04X", monitor_id_string, ctx->source.id, monitor.id );
|
||||
set_reg_ascii_value( ctx->source_key, buffer, monitor.path );
|
||||
|
||||
if (!write_monitor_to_registry( &monitor, gdi_monitor->edid, gdi_monitor->edid_len ))
|
||||
|
@ -1563,7 +1563,7 @@ static void enum_device_keys( const char *root, const WCHAR *classW, UINT class_
|
|||
char path[MAX_PATH];
|
||||
|
||||
if (!(root_key = reg_open_ascii_key( enum_key, root ))) return;
|
||||
root_len = sprintf( path, "%s\\", root );
|
||||
root_len = snprintf( path, sizeof(path), "%s\\", root );
|
||||
|
||||
while (!NtEnumerateKey( root_key, i++, KeyBasicInformation, key2, sizeof(buffer), &size ))
|
||||
{
|
||||
|
@ -2698,8 +2698,8 @@ static void monitor_get_interface_name( struct monitor *monitor, WCHAR *interfac
|
|||
if (!(monitor->edid_info.flags & MONITOR_INFO_HAS_MONITOR_ID)) id = "Default_Monitor";
|
||||
else id = monitor->edid_info.monitor_id_string;
|
||||
|
||||
sprintf( buffer, "\\\\?\\DISPLAY\\%s\\%04X&%04X#%s", id, monitor->source->id,
|
||||
monitor->id, guid_devinterface_monitorA );
|
||||
snprintf( buffer, sizeof(buffer), "\\\\?\\DISPLAY\\%s\\%04X&%04X#%s", id, monitor->source->id,
|
||||
monitor->id, guid_devinterface_monitorA );
|
||||
for (tmp = buffer + 4; *tmp; tmp++) if (*tmp == '\\') *tmp = '#';
|
||||
|
||||
asciiz_to_unicode( interface_name, buffer );
|
||||
|
@ -2736,8 +2736,8 @@ NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
|
|||
|
||||
if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceName) + sizeof(info->DeviceName))
|
||||
{
|
||||
if (monitor) sprintf( buffer, "\\\\.\\DISPLAY%d\\Monitor%d", source->id + 1, monitor->id );
|
||||
else sprintf( buffer, "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
if (monitor) snprintf( buffer, sizeof(buffer), "\\\\.\\DISPLAY%d\\Monitor%d", source->id + 1, monitor->id );
|
||||
else snprintf( buffer, sizeof(buffer), "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
asciiz_to_unicode( info->DeviceName, buffer );
|
||||
}
|
||||
if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceString) + sizeof(info->DeviceString))
|
||||
|
@ -2765,9 +2765,9 @@ NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
|
|||
{
|
||||
if (monitor)
|
||||
{
|
||||
sprintf( buffer, "MONITOR\\%s", monitor->path + 8 );
|
||||
snprintf( buffer, sizeof(buffer), "MONITOR\\%s", monitor->path + 8 );
|
||||
if (!(tmp = strrchr( buffer, '\\' ))) tmp = buffer + strlen( buffer );
|
||||
sprintf( tmp, "\\%s\\%04X", guid_devclass_monitorA, monitor->output_id );
|
||||
snprintf( tmp, sizeof(buffer) - (tmp - buffer), "\\%s\\%04X", guid_devclass_monitorA, monitor->output_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2779,8 +2779,8 @@ NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
|
|||
}
|
||||
if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(info->DeviceKey))
|
||||
{
|
||||
if (monitor) sprintf( buffer, "%s\\Class\\%s\\%04X", control_keyA, guid_devclass_monitorA, monitor->output_id );
|
||||
else sprintf( buffer, "%s\\Video\\%s\\%04x", control_keyA, source->gpu->guid, source->id );
|
||||
if (monitor) snprintf( buffer, sizeof(buffer), "%s\\Class\\%s\\%04X", control_keyA, guid_devclass_monitorA, monitor->output_id );
|
||||
else snprintf( buffer, sizeof(buffer), "%s\\Video\\%s\\%04x", control_keyA, source->gpu->guid, source->id );
|
||||
asciiz_to_unicode( info->DeviceKey, buffer );
|
||||
}
|
||||
}
|
||||
|
@ -2791,7 +2791,7 @@ NTSTATUS WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
|
|||
#define _X_FIELD(prefix, bits) \
|
||||
if ((fields) & prefix##_##bits) \
|
||||
{ \
|
||||
p += sprintf( p, "%s%s", first ? "" : ",", #bits ); \
|
||||
p += snprintf( p, sizeof(buf) - (p - buf), "%s%s", first ? "" : ",", #bits ); \
|
||||
first = FALSE; \
|
||||
}
|
||||
|
||||
|
@ -2983,7 +2983,7 @@ static DEVMODEW *get_display_settings( struct source *target, const DEVMODEW *de
|
|||
}
|
||||
}
|
||||
|
||||
sprintf( buffer, "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
snprintf( buffer, sizeof(buffer), "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
asciiz_to_unicode( mode->dmDeviceName, buffer );
|
||||
mode = NEXT_DEVMODEW(mode);
|
||||
}
|
||||
|
@ -3207,7 +3207,7 @@ static LONG apply_display_settings( struct source *target, const DEVMODEW *devmo
|
|||
else
|
||||
{
|
||||
char device_name[CCHDEVICENAME];
|
||||
sprintf( device_name, "\\\\.\\DISPLAY%d", primary->id + 1 );
|
||||
snprintf( device_name, sizeof(device_name), "\\\\.\\DISPLAY%d", primary->id + 1 );
|
||||
asciiz_to_unicode( primary_name, device_name );
|
||||
}
|
||||
|
||||
|
@ -3387,7 +3387,7 @@ INT get_display_depth( UNICODE_STRING *name )
|
|||
}
|
||||
|
||||
is_primary = !!(source->state_flags & DISPLAY_DEVICE_PRIMARY_DEVICE);
|
||||
sprintf( device_name, "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
snprintf( device_name, sizeof(device_name), "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
asciiz_to_unicode( device_nameW, device_name );
|
||||
|
||||
/* use the default implementation in virtual desktop mode */
|
||||
|
@ -3520,7 +3520,7 @@ BOOL get_monitor_info( HMONITOR handle, MONITORINFO *info )
|
|||
if (info->cbSize >= sizeof(MONITORINFOEXW))
|
||||
{
|
||||
char buffer[CCHDEVICENAME];
|
||||
if (monitor->source) sprintf( buffer, "\\\\.\\DISPLAY%d", monitor->source->id + 1 );
|
||||
if (monitor->source) snprintf( buffer, sizeof(buffer), "\\\\.\\DISPLAY%d", monitor->source->id + 1 );
|
||||
else strcpy( buffer, "WinDisc" );
|
||||
asciiz_to_unicode( ((MONITORINFOEXW *)info)->szDevice, buffer );
|
||||
}
|
||||
|
@ -3830,7 +3830,7 @@ static BOOL set_int_entry( union sysparam_all_entry *entry, UINT int_param, void
|
|||
WCHAR bufW[32];
|
||||
char buf[32];
|
||||
|
||||
sprintf( buf, "%d", int_param );
|
||||
snprintf( buf, sizeof(buf), "%d", int_param );
|
||||
asciiz_to_unicode( bufW, buf );
|
||||
if (!save_entry_string( &entry->hdr, bufW, flags )) return FALSE;
|
||||
entry->uint.val = int_param;
|
||||
|
@ -3844,7 +3844,7 @@ static BOOL init_int_entry( union sysparam_all_entry *entry )
|
|||
WCHAR bufW[32];
|
||||
char buf[32];
|
||||
|
||||
sprintf( buf, "%d", entry->uint.val );
|
||||
snprintf( buf, sizeof(buf), "%d", entry->uint.val );
|
||||
asciiz_to_unicode( bufW, buf );
|
||||
return init_entry_string( &entry->hdr, bufW );
|
||||
}
|
||||
|
@ -3869,7 +3869,7 @@ static BOOL set_uint_entry( union sysparam_all_entry *entry, UINT int_param, voi
|
|||
WCHAR bufW[32];
|
||||
char buf[32];
|
||||
|
||||
sprintf( buf, "%u", int_param );
|
||||
snprintf( buf, sizeof(buf), "%u", int_param );
|
||||
asciiz_to_unicode( bufW, buf );
|
||||
if (!save_entry_string( &entry->hdr, bufW, flags )) return FALSE;
|
||||
entry->uint.val = int_param;
|
||||
|
@ -3883,7 +3883,7 @@ static BOOL init_uint_entry( union sysparam_all_entry *entry )
|
|||
WCHAR bufW[32];
|
||||
char buf[32];
|
||||
|
||||
sprintf( buf, "%u", entry->uint.val );
|
||||
snprintf( buf, sizeof(buf), "%u", entry->uint.val );
|
||||
asciiz_to_unicode( bufW, buf );
|
||||
return init_entry_string( &entry->hdr, bufW );
|
||||
}
|
||||
|
@ -4059,7 +4059,7 @@ static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void
|
|||
HBRUSH brush;
|
||||
HPEN pen;
|
||||
|
||||
sprintf( buf, "%u %u %u", GetRValue(int_param), GetGValue(int_param), GetBValue(int_param) );
|
||||
snprintf( buf, sizeof(buf), "%u %u %u", GetRValue(int_param), GetGValue(int_param), GetBValue(int_param) );
|
||||
asciiz_to_unicode( bufW, buf );
|
||||
if (!save_entry_string( &entry->hdr, bufW, flags )) return FALSE;
|
||||
entry->rgb.val = int_param;
|
||||
|
@ -4083,8 +4083,8 @@ static BOOL init_rgb_entry( union sysparam_all_entry *entry )
|
|||
WCHAR bufW[32];
|
||||
char buf[32];
|
||||
|
||||
sprintf( buf, "%u %u %u", GetRValue(entry->rgb.val), GetGValue(entry->rgb.val),
|
||||
GetBValue(entry->rgb.val) );
|
||||
snprintf( buf, sizeof(buf), "%u %u %u", GetRValue(entry->rgb.val), GetGValue(entry->rgb.val),
|
||||
GetBValue(entry->rgb.val) );
|
||||
asciiz_to_unicode( bufW, buf );
|
||||
return init_entry_string( &entry->hdr, bufW );
|
||||
}
|
||||
|
@ -6449,7 +6449,7 @@ NTSTATUS WINAPI NtUserDisplayConfigGetDeviceInfo( DISPLAYCONFIG_DEVICE_INFO_HEAD
|
|||
if (source_name->header.id != source->id) continue;
|
||||
if (memcmp( &source_name->header.adapterId, &source->gpu->luid, sizeof(source->gpu->luid) )) continue;
|
||||
|
||||
sprintf( buffer, "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
snprintf( buffer, sizeof(buffer), "\\\\.\\DISPLAY%d", source->id + 1 );
|
||||
asciiz_to_unicode( source_name->viewGdiDeviceName, buffer );
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
|
|
|
@ -566,7 +566,7 @@ static HANDLE get_winstations_dir_handle(void)
|
|||
NTSTATUS status;
|
||||
HANDLE dir;
|
||||
|
||||
sprintf( bufferA, "\\Sessions\\%u\\Windows\\WindowStations", (int)NtCurrentTeb()->Peb->SessionId );
|
||||
snprintf( bufferA, sizeof(bufferA), "\\Sessions\\%u\\Windows\\WindowStations", (int)NtCurrentTeb()->Peb->SessionId );
|
||||
str.Buffer = buffer;
|
||||
str.MaximumLength = asciiz_to_unicode( buffer, bufferA );
|
||||
str.Length = str.MaximumLength - sizeof(WCHAR);
|
||||
|
|
Loading…
Reference in a new issue