From ba6132715c356e5fd35f38747bb4477bec132863 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 31 Jan 2018 11:40:58 +0000 Subject: [PATCH] Don't try to make callback with invalid SteamAPICall_t --- .../SteamNative/SteamNative.SteamApps.cs | 1 + .../SteamNative/SteamNative.SteamFriends.cs | 6 ++++++ .../SteamNative.SteamGameServer.cs | 3 +++ .../SteamNative.SteamGameServerStats.cs | 2 ++ .../SteamNative.SteamHTMLSurface.cs | 1 + .../SteamNative/SteamNative.SteamInventory.cs | 3 +++ .../SteamNative.SteamMatchmaking.cs | 3 +++ .../SteamNative.SteamRemoteStorage.cs | 21 +++++++++++++++++++ .../SteamNative/SteamNative.SteamUGC.cs | 18 ++++++++++++++++ .../SteamNative/SteamNative.SteamUser.cs | 2 ++ .../SteamNative/SteamNative.SteamUserStats.cs | 10 +++++++++ .../SteamNative/SteamNative.SteamUtils.cs | 1 + Generator/CodeWriter/Class.cs | 1 + 13 files changed, 72 insertions(+) diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs index 61114d5..2f28d3c 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApps.cs @@ -184,6 +184,7 @@ public CallbackHandle GetFileDetails( string pszFileName /*const char **/, Actio callback = platform.ISteamApps_GetFileDetails( pszFileName ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return FileDetailsResult_t.CallResult( steamworks, callback, CallbackFunction ); } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs index 822fb33..6734548 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamFriends.cs @@ -98,6 +98,7 @@ public CallbackHandle EnumerateFollowingList( uint unStartIndex /*uint32*/, Acti callback = platform.ISteamFriends_EnumerateFollowingList( unStartIndex ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return FriendsEnumerateFollowingList_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -193,6 +194,7 @@ public CallbackHandle GetFollowerCount( CSteamID steamID /*class CSteamID*/, Act callback = platform.ISteamFriends_GetFollowerCount( steamID.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return FriendsGetFollowerCount_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -429,6 +431,7 @@ public CallbackHandle IsFollowing( CSteamID steamID /*class CSteamID*/, Action Callback callback = platform.ISteamGameServer_GetServerReputation(); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return GSReputation_t.CallResult( steamworks, callback, CallbackFunction ); } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs index 14cb187..706408c 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamGameServerStats.cs @@ -74,6 +74,7 @@ public CallbackHandle RequestUserStats( CSteamID steamIDUser /*class CSteamID*/, callback = platform.ISteamGameServerStats_RequestUserStats( steamIDUser.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return GSStatsReceived_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -103,6 +104,7 @@ public CallbackHandle StoreUserStats( CSteamID steamIDUser /*class CSteamID*/, A callback = platform.ISteamGameServerStats_StoreUserStats( steamIDUser.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return GSStatsStored_t.CallResult( steamworks, callback, CallbackFunction ); } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs index 1d6b917..3f434bb 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamHTMLSurface.cs @@ -68,6 +68,7 @@ public CallbackHandle CreateBrowser( string pchUserAgent /*const char **/, strin callback = platform.ISteamHTMLSurface_CreateBrowser( pchUserAgent, pchUserCSS ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return HTML_BrowserReady_t.CallResult( steamworks, callback, CallbackFunction ); } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs index 75da1b4..d6de777 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamInventory.cs @@ -243,6 +243,7 @@ public CallbackHandle RequestEligiblePromoItemDefinitionsIDs( CSteamID steamID / callback = platform.ISteamInventory_RequestEligiblePromoItemDefinitionsIDs( steamID.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return SteamInventoryEligiblePromoItemDefIDs_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -254,6 +255,7 @@ public CallbackHandle RequestPrices( Action x.Value ).ToArray(), punArrayQuantity, unArrayLength ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return SteamInventoryStartPurchaseResult_t.CallResult( steamworks, callback, CallbackFunction ); } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs index 97c80e2..da740fe 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamMatchmaking.cs @@ -98,6 +98,7 @@ public CallbackHandle CreateLobby( LobbyType eLobbyType /*ELobbyType*/, int cMax callback = platform.ISteamMatchmaking_CreateLobby( eLobbyType, cMaxMembers ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return LobbyCreated_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -219,6 +220,7 @@ public CallbackHandle JoinLobby( CSteamID steamIDLobby /*class CSteamID*/, Actio callback = platform.ISteamMatchmaking_JoinLobby( steamIDLobby.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return LobbyEnter_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -248,6 +250,7 @@ public CallbackHandle RequestLobbyList( Action CallbackF callback = platform.ISteamMatchmaking_RequestLobbyList(); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return LobbyMatchList_t.CallResult( steamworks, callback, CallbackFunction ); } diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs index 8493623..22de4be 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamRemoteStorage.cs @@ -50,6 +50,7 @@ public CallbackHandle CommitPublishedFileUpdate( PublishedFileUpdateHandle_t upd callback = platform.ISteamRemoteStorage_CommitPublishedFileUpdate( updateHandle.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageUpdatePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -67,6 +68,7 @@ public CallbackHandle DeletePublishedFile( PublishedFileId_t unPublishedFileId / callback = platform.ISteamRemoteStorage_DeletePublishedFile( unPublishedFileId.Value ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageDeletePublishedFileResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -78,6 +80,7 @@ public CallbackHandle EnumeratePublishedFilesByUserAction( WorkshopFileAction eA callback = platform.ISteamRemoteStorage_EnumeratePublishedFilesByUserAction( eAction, unStartIndex ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageEnumeratePublishedFilesByUserActionResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -115,6 +118,7 @@ public CallbackHandle EnumeratePublishedWorkshopFiles( WorkshopEnumerationType e } if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageEnumerateWorkshopFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -126,6 +130,7 @@ public CallbackHandle EnumerateUserPublishedFiles( uint unStartIndex /*uint32*/, callback = platform.ISteamRemoteStorage_EnumerateUserPublishedFiles( unStartIndex ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageEnumerateUserPublishedFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -163,6 +168,7 @@ public CallbackHandle EnumerateUserSharedWorkshopFiles( CSteamID steamId /*class } if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageEnumerateUserPublishedFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -174,6 +180,7 @@ public CallbackHandle EnumerateUserSubscribedFiles( uint unStartIndex /*uint32*/ callback = platform.ISteamRemoteStorage_EnumerateUserSubscribedFiles( unStartIndex ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageEnumerateUserSubscribedFilesResult_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -215,6 +222,7 @@ public CallbackHandle FileReadAsync( string pchFile /*const char **/, uint nOffs callback = platform.ISteamRemoteStorage_FileReadAsync( pchFile, nOffset, cubToRead ); if ( CallbackFunction == null ) return null; + if ( callback == 0 ) return null; return RemoteStorageFileReadAsyncComplete_t.CallResult( steamworks, callback, CallbackFunction ); } @@ -232,6 +240,7 @@ public CallbackHandle FileShare( string pchFile /*const char **/, Action argList, List callargs AfterLines.Add( "" ); AfterLines.Add( "if ( CallbackFunction == null ) return null;" ); + AfterLines.Add("if ( callback == 0 ) return null;"); AfterLines.Add( "" ); AfterLines.Add( $"return {MethodDef.CallResult}.CallResult( steamworks, callback, CallbackFunction );" );