102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
dttr_errors.h File Reference
#include <stdlib.h>
#include <dttr_log.h>
#include <sds.h>
#include <windows.h>

Go to the source code of this file.

Macros

#define DTTR_ERROR_TITLE   "DttR: Error"
#define DTTR_FATAL_ERROR_TITLE   "DttR: Fatal Error"
#define DTTR_ERROR(error_message, ...)
#define DTTR_REPORT_SUFFIX
#define DTTR_FATAL(error_message, ...)
#define DTTR_UNWRAP_WINAPI()
#define DTTR_UNWRAP_WINAPI_IF(result, is_error)
#define DTTR_UNWRAP_WINAPI_NONNEGATIVE_IS_ERROR(x)
#define DTTR_UNWRAP_WINAPI_NONNEGATIVE(result)
#define DTTR_UNWRAP_WINAPI_NONZERO_IS_ERROR(x)
#define DTTR_UNWRAP_WINAPI_NONZERO(result)
#define DTTR_UNWRAP_WINAPI_EXISTS_IS_ERROR(x)
#define DTTR_UNWRAP_WINAPI_EXISTS(result)

Typedefs

typedef void(* DTTR_ErrorMessageHandler) (const char *title, const char *message)

Functions

void DTTR_Errors_SetMessageHandler (DTTR_ErrorMessageHandler handler)
void DTTR_Errors_ShowMessage (const char *title, const char *message)

Macro Definition Documentation

◆ DTTR_ERROR

#define DTTR_ERROR ( error_message,
... )
Value:
do { \
sds _err_msg = sdscatprintf(sdsempty(), error_message, ##__VA_ARGS__); \
DTTR_LOG_ERROR("%s", _err_msg); \
DTTR_Errors_ShowMessage(DTTR_ERROR_TITLE, _err_msg); \
sdsfree(_err_msg); \
} while (0)
#define DTTR_ERROR_TITLE
Definition dttr_errors.h:15

Definition at line 18 of file dttr_errors.h.

Referenced by dttr_launcher_main(), DTTR_Loader_WatchdogWait(), and write_child_dump().

◆ DTTR_ERROR_TITLE

#define DTTR_ERROR_TITLE   "DttR: Error"

Definition at line 15 of file dttr_errors.h.

Referenced by write_child_dump().

◆ DTTR_FATAL

#define DTTR_FATAL ( error_message,
... )
Value:
do { \
sds _err_msg = sdscatprintf(sdsempty(), error_message, ##__VA_ARGS__); \
_err_msg = sdscat(_err_msg, DTTR_REPORT_SUFFIX); \
DTTR_LOG_ERROR("%s", _err_msg); \
DTTR_Errors_ShowMessage(DTTR_FATAL_ERROR_TITLE, _err_msg); \
sdsfree(_err_msg); \
exit(EXIT_FAILURE); \
} while (0)
#define DTTR_REPORT_SUFFIX
Definition dttr_errors.h:26
#define DTTR_FATAL_ERROR_TITLE
Definition dttr_errors.h:16

Definition at line 30 of file dttr_errors.h.

Referenced by DTTR_Compat_CreateProcess(), DTTR_Hook_WinMainCallback(), dttr_launcher_main(), resolve_config_path(), resolve_nt_path_and_cwd(), and unload_mod().

◆ DTTR_FATAL_ERROR_TITLE

#define DTTR_FATAL_ERROR_TITLE   "DttR: Fatal Error"

Definition at line 16 of file dttr_errors.h.

◆ DTTR_REPORT_SUFFIX

#define DTTR_REPORT_SUFFIX
Value:
"\n\nFeel free to report this error as an " \
"issue if it's unexpected:\nhttps://gitlab.com/dogstuff/detours-to-the-rescue\n"

Definition at line 26 of file dttr_errors.h.

Referenced by DTTR_CrashDump_AppendReportMessage(), dttr_launcher_main(), and DTTR_Loader_WatchdogWait().

◆ DTTR_UNWRAP_WINAPI

#define DTTR_UNWRAP_WINAPI ( )
Value:
do { \
DWORD error_code = GetLastError(); \
if (error_code == ERROR_SUCCESS) { \
break; \
} \
LPSTR message = NULL; \
FormatMessageA( \
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM \
| FORMAT_MESSAGE_IGNORE_INSERTS, \
NULL, \
error_code, \
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
(LPSTR) & message, \
0, \
NULL \
); \
const char *message_text = message ? message : "unknown"; \
DTTR_FATAL("Win32 API Error 0x%lX: %s", error_code, message_text); \
} while (0)
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL

Definition at line 40 of file dttr_errors.h.

◆ DTTR_UNWRAP_WINAPI_EXISTS

#define DTTR_UNWRAP_WINAPI_EXISTS ( result)
Value:
#define DTTR_UNWRAP_WINAPI_IF(result, is_error)
Definition dttr_errors.h:61
#define DTTR_UNWRAP_WINAPI_EXISTS_IS_ERROR(x)
Definition dttr_errors.h:78

Definition at line 79 of file dttr_errors.h.

Referenced by DllMain(), DTTR_Compat_CreateProcess(), and write_remote_shim_data().

◆ DTTR_UNWRAP_WINAPI_EXISTS_IS_ERROR

#define DTTR_UNWRAP_WINAPI_EXISTS_IS_ERROR ( x)
Value:
((x) == NULL)
DTTR_Graphics_COM_DirectDrawSurface7 DWORD x

Definition at line 78 of file dttr_errors.h.

◆ DTTR_UNWRAP_WINAPI_IF

#define DTTR_UNWRAP_WINAPI_IF ( result,
is_error )
Value:
__extension__({ \
__typeof__(result) _r = (result); \
if (is_error(_r)) { \
DTTR_UNWRAP_WINAPI(); \
} \
_r; \
})

Definition at line 61 of file dttr_errors.h.

◆ DTTR_UNWRAP_WINAPI_NONNEGATIVE

#define DTTR_UNWRAP_WINAPI_NONNEGATIVE ( result)
Value:

Definition at line 71 of file dttr_errors.h.

◆ DTTR_UNWRAP_WINAPI_NONNEGATIVE_IS_ERROR

#define DTTR_UNWRAP_WINAPI_NONNEGATIVE_IS_ERROR ( x)
Value:
((x) < 0)

Definition at line 70 of file dttr_errors.h.

◆ DTTR_UNWRAP_WINAPI_NONZERO

#define DTTR_UNWRAP_WINAPI_NONZERO ( result)
Value:

Definition at line 75 of file dttr_errors.h.

Referenced by DTTR_Compat_CreateProcess(), and write_remote_shim_data().

◆ DTTR_UNWRAP_WINAPI_NONZERO_IS_ERROR

#define DTTR_UNWRAP_WINAPI_NONZERO_IS_ERROR ( x)
Value:
((x) == FALSE)
DTTR_Graphics_COM_Direct3DDevice7 DWORD block DTTR_Graphics_COM_Direct3DDevice7 DWORD block DTTR_Graphics_COM_Direct3DDevice7 void void void void DWORD f FALSE

Definition at line 74 of file dttr_errors.h.

Typedef Documentation

◆ DTTR_ErrorMessageHandler

typedef void(* DTTR_ErrorMessageHandler) (const char *title, const char *message)

Definition at line 10 of file dttr_errors.h.

Function Documentation

◆ DTTR_Errors_SetMessageHandler()

void DTTR_Errors_SetMessageHandler ( DTTR_ErrorMessageHandler handler)

Definition at line 6 of file errors.c.

References message_handler.

Referenced by dttr_launcher_main().

◆ DTTR_Errors_ShowMessage()

void DTTR_Errors_ShowMessage ( const char * title,
const char * message )

Definition at line 10 of file errors.c.

References DTTR_SDL_ShowSimpleMessageBox(), message_handler, and NULL.

Referenced by dttr_graphics_init(), and write_child_dump().