From 725044535fe3f8fd48d2f0eae1cec3515d789763 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 16 Jan 2025 21:42:29 +0100 Subject: [PATCH] lsteamclient: Pad some client pointers. --- lsteamclient/unixlib.cpp | 14 ++++++------ lsteamclient/unixlib.h | 48 +++++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/lsteamclient/unixlib.cpp b/lsteamclient/unixlib.cpp index 273475d5..57e42d57 100644 --- a/lsteamclient/unixlib.cpp +++ b/lsteamclient/unixlib.cpp @@ -51,7 +51,7 @@ void queue_vtable_callback( struct w_iface *w_iface, enum callback_type type, ui uint32_t size = 0; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = type; size -= offsetof( struct callback_entry, callback ); @@ -72,7 +72,7 @@ void queue_vtable_callback_0_server_responded( struct w_iface *w_iface, gameserv struct callback_entry *entry; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = CALL_IFACE_VTABLE_0_SERVER_RESPONDED; size -= offsetof( struct callback_entry, callback ); @@ -92,7 +92,7 @@ void queue_vtable_callback_0_add_player_to_list( struct w_iface *w_iface, const struct callback_entry *entry; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = CALL_IFACE_VTABLE_0_ADD_PLAYER_TO_LIST; size -= offsetof( struct callback_entry, callback ); @@ -114,7 +114,7 @@ void queue_vtable_callback_0_rules_responded( struct w_iface *w_iface, const cha struct callback_entry *entry; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = CALL_IFACE_VTABLE_0_RULES_RESPONDED; size -= offsetof( struct callback_entry, callback ); @@ -136,7 +136,7 @@ static void u_steam_networking_socket_debug_output( uint32_t nType, const char * struct callback_entry *entry; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = SOCKETS_DEBUG_OUTPUT; size -= offsetof( struct callback_entry, callback ); @@ -157,7 +157,7 @@ void queue_cdecl_func_callback( w_cdecl_func func, void *data, uint32_t data_siz struct callback_entry *entry; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = CALL_CDECL_FUNC_DATA; size -= offsetof( struct callback_entry, callback ); @@ -184,7 +184,7 @@ static void u_steam_api_warning_message_hook( int severity, const char *msg ) struct callback_entry *entry; size += sizeof(struct callback_entry); - if (!(entry = (struct callback_entry *)malloc( size ))) return; + if (!(entry = (struct callback_entry *)calloc( 1, size ))) return; entry->callback.type = WARNING_MESSAGE_HOOK; size -= offsetof( struct callback_entry, callback ); diff --git a/lsteamclient/unixlib.h b/lsteamclient/unixlib.h index 17260d81..c841475a 100644 --- a/lsteamclient/unixlib.h +++ b/lsteamclient/unixlib.h @@ -66,40 +66,64 @@ struct callback { struct { - void (*W_CDECL pfnFunc)( uint32_t, const char * ); + union + { + void (*W_CDECL pfnFunc)( uint32_t, const char * ); + UINT64 __pad; + }; uint32_t type; const char msg[1]; } sockets_debug_output; struct { - void (*W_CDECL pFunction)( int32_t, const char * ); + union + { + void (*W_CDECL pFunction)( int32_t, const char * ); + UINT64 __pad; + }; int32_t severity; const char msg[1]; } warning_message_hook; struct { - void (*W_CDECL pFunc)( void * ); + union + { + void (*W_CDECL pFunc)( void * ); + UINT64 __pad; + }; unsigned char data[1]; } call_cdecl_func_data; struct { - struct w_iface *iface; + union + { + struct w_iface *iface; + UINT64 __pad; + }; uint64_t arg0; uint64_t arg1; } call_iface_vtable; struct { - struct w_iface *iface; + union + { + struct w_iface *iface; + UINT64 __pad; + }; gameserveritem_t_105 server[]; } server_responded; struct { - struct w_iface *iface; + union + { + struct w_iface *iface; + UINT64 __pad; + }; int32_t score; float time_played; const char name[1]; @@ -107,7 +131,11 @@ struct callback struct { - struct w_iface *iface; + union + { + struct w_iface *iface; + UINT64 __pad; + }; const char rule_and_value[1]; } rules_responded; }; @@ -241,7 +269,11 @@ struct w_request { struct u_request u_request; struct u_response u_response; - gameserveritem_t_105 *details; + union + { + gameserveritem_t_105 *details; + UINT64 __pad; + }; }; #include