What is SteamAPI WriteMiniDump?
SteamAPI WriteMiniDump is a function that writes and uploads a minidump to report crashes in your game. A minidump is a small file that contains information about the state of your program when it crashed, such as the call stack, the registers, and the exception code.
SteamAPI WriteMiniDump is part of the Steamworks API, which is a set of tools and services that enable game developers to integrate their games with Steam. The Steamworks API provides features such as achievements, leaderboards, matchmaking, cloud storage, and more.
The Steamworks API also provides a crash reporting system that automatically collects and uploads minidumps from your game to Steam. This system helps developers to identify and fix the most common and critical issues that affect their players.
How does SteamAPI WriteMiniDump work?
SteamAPI WriteMiniDump works by registering a custom exception handler that intercepts any unhandled exceptions that occur in your game. When an exception occurs, the function writes a minidump file to a temporary folder and then uploads it to Steam using the HTTP API.
The minidump file contains the following information:
The name and version of your game
The name and version of the Steam client
The operating system and hardware configuration of the user's machine
The exception code and address that caused the crash
The call stack of the thread that crashed
The values of the registers at the time of the crash
The memory regions around the instruction pointer and the stack pointer
Any custom comments or data that you provide using SteamAPI_SetMiniDumpComment or SteamAPI_SetMiniDumpCustomData
The minidump file does not contain any personal or sensitive information from the user's machine, such as files, passwords, or keystrokes.
How to use SteamAPI WriteMiniDump to report crashes in your game?
To use SteamAPI WriteMiniDump to report crashes in your game, you need to do the following steps:
Initialize the Steamworks API by calling SteamAPI_Init at the start of your game. This function will return true if the API was initialized successfully, or false if there was an error. You should check the return value and handle any errors accordingly.
Check if your game was launched through Steam by calling SteamAPI_RestartAppIfNecessary with your App ID as an argument. This function will return true if your game needs to be restarted through Steam, or false if not. You should quit your game immediately if this function returns true.
Optionally, set a custom comment or data for your minidump by calling SteamAPI_SetMiniDumpComment or SteamAPI_SetMiniDumpCustomData before any exceptions occur. These functions allow you to add additional information to your minidump, such as a build ID, a version number, or a user ID.
If an exception occurs in your game, SteamAPI WriteMiniDump will automatically write and upload a minidump file to Steam. You do not need to call this function explicitly.
You can view and analyze the minidumps from your game by logging into your partner account on [Steamworks] and navigating to Reports > Crash Reports. You can also download the minidumps for offline debugging using tools such as [WinDbg] or [Visual Studio].
Here is an example of how to initialize the Steamworks API and check if your game was launched through Steam in C++:
#include "steam_api.h" #define APP_ID 123456 // Replace with your App ID int main()
// Initialize the Steamworks API if (!SteamAPI_Init()) printf("Fatal Error - Steam must be running to play this game (SteamAPI_Init() failed).\n"); return 1; // Check if the game was launched through Steam if (SteamAPI_RestartAppIfNecessary(APP_ID)) printf("Restarting the game through Steam.\n"); return 1; // Run the game logic // ... // Shutdown the Steamworks API SteamAPI_Shutdown(); return 0;
For more information and examples on how to use the Steamworks API, you can refer to the [Steamworks Documentation] and the [Steamworks SDK].
a104e7fe7e