HyperDbg Debugger
Loading...
Searching...
No Matches
messaging.cpp File Reference

Functions for handling messages. More...

#include "pch.h"

Functions

VOID SetTextMessageCallback (PVOID Handler)
 Set the function callback that will be called if any message needs to be shown.
PVOID SetTextMessageCallbackUsingSharedBuffer (PVOID Handler)
 Set the function callback that will be called if any message needs to be shown.
VOID UnsetTextMessageCallback ()
 Unset the function callback that will be called if any message needs to be shown.
VOID ShowMessages (const CHAR *Fmt,...)
 Show messages.

Variables

PVOID g_MessageHandler
 The handler for ShowMessages function this is because the user might choose not to use printf and instead use his/her handler for showing messages.
PVOID g_MessageHandlerSharedBuffer
 The shared buffer for the handler of ShowMessages function.
BOOLEAN g_LogOpened
 Shows whether the '.logopen' command is executed and the log file is open or not.
BOOLEAN g_IsConnectedToRemoteDebugger
 Shows whether the current system is a guest (debuggee) and a remote debugger is connected to this system.
BOOLEAN g_IsSerialConnectedToRemoteDebugger
 Shows if the debugger was connected to remote debugger (A remote host).

Detailed Description

Functions for handling messages.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.19
Date
2026-05-28

Function Documentation

◆ SetTextMessageCallback()

VOID SetTextMessageCallback ( PVOID Handler)

Set the function callback that will be called if any message needs to be shown.

Parameters
HandlerFunction that handles the messages
Returns
VOID
34{
35 g_MessageHandler = Handler;
36}
PVOID g_MessageHandler
The handler for ShowMessages function this is because the user might choose not to use printf and ins...
Definition globals.h:460

◆ SetTextMessageCallbackUsingSharedBuffer()

PVOID SetTextMessageCallbackUsingSharedBuffer ( PVOID Handler)

Set the function callback that will be called if any message needs to be shown.

Parameters
HandlerFunction that handles the messages
Returns
PVOID
47{
48 g_MessageHandler = Handler;
50
52 {
54 return NULL;
55 }
56
58
60}
#define TCP_END_OF_BUFFER_CHARS_COUNT
count of characters for tcp end of buffer
Definition Constants.h:442
#define COMMUNICATION_BUFFER_SIZE
Packet size for TCP connections.
Definition Constants.h:338
PVOID g_MessageHandlerSharedBuffer
The shared buffer for the handler of ShowMessages function.
Definition globals.h:466
NULL()
Definition test-case-generator.py:530

◆ ShowMessages()

VOID ShowMessages ( const CHAR * Fmt,
... )

Show messages.

Parameters
Fmtformat string message
...arguments
Returns
VOID
85{
86 va_list ArgList;
87 va_list Args;
89
91 {
92 va_start(Args, Fmt);
93
94 vprintf(Fmt, Args);
95
96 va_end(Args);
97
98 if (!g_LogOpened)
99 {
100 return;
101 }
102 }
103
104 va_start(ArgList, Fmt);
105
106 INT SprintfResult = PlatformVsnprintf(TempMessage, sizeof(TempMessage), Fmt, ArgList);
107
108 va_end(ArgList);
109
110 if (SprintfResult != -1)
111 {
113 {
114 //
115 // vsprintf_s and vswprintf_s return the number of characters written,
116 // not including the terminating null character, or a negative value
117 // if an output error occurs.
118 //
119 RemoteConnectionSendResultsToHost(TempMessage, SprintfResult);
120 }
122 {
123 KdSendUsermodePrints(TempMessage, SprintfResult);
124 }
125
126 if (g_LogOpened)
127 {
128 //
129 // .logopen command executed
130 //
131 LogopenSaveToFile(TempMessage);
132 }
133 if (g_MessageHandler != NULL)
134 {
135 //
136 // There is another handler
137 //
139 {
141 }
142 else
143 {
144 memcpy(g_MessageHandlerSharedBuffer, TempMessage, strlen(TempMessage) + 1);
146 }
147 }
148 }
149}
int INT
Definition BasicTypes.h:43
char CHAR
Definition BasicTypes.h:33
int(* SendMessageWithSharedBufferCallback)(VOID)
Callback type that can be used to be used as a custom ShowMessages function (using shared buffer).
Definition DataTypes.h:162
int(* SendMessageWithParamCallback)(const char *Text)
Callback type that can be used to be used as a custom ShowMessages function (by passing message as a ...
Definition DataTypes.h:155
VOID KdSendUsermodePrints(CHAR *Input, UINT32 Length)
Send result of user-mode ShowMessages to debuggee.
Definition kd.cpp:3364
VOID LogopenSaveToFile(const CHAR *Text)
Append text to the file object.
Definition logopen.cpp:110
BOOLEAN g_IsSerialConnectedToRemoteDebugger
Shows if the debugger was connected to remote debugger (A remote host).
Definition rev.cpp:18
BOOLEAN g_LogOpened
Shows whether the '.logopen' command is executed and the log file is open or not.
Definition globals.h:488
BOOLEAN g_IsConnectedToRemoteDebugger
Shows whether the current system is a guest (debuggee) and a remote debugger is connected to this sys...
Definition globals.h:103
INT PlatformVsnprintf(char *Buffer, SIZE_T BufferSize, const char *Format, va_list ArgList)
Platform independent wrapper for vsprintf_s / vsnprintf.
Definition platform-lib-calls.c:33
INT RemoteConnectionSendResultsToHost(const CHAR *sendbuf, INT len)
Send the results of executing a command from deubggee (server, guest) to the debugger (client,...
Definition remote-connection.cpp:481

◆ UnsetTextMessageCallback()

VOID UnsetTextMessageCallback ( )

Unset the function callback that will be called if any message needs to be shown.

Returns
VOID

Variable Documentation

◆ g_IsConnectedToRemoteDebugger

BOOLEAN g_IsConnectedToRemoteDebugger
extern

Shows whether the current system is a guest (debuggee) and a remote debugger is connected to this system.

◆ g_IsSerialConnectedToRemoteDebugger

BOOLEAN g_IsSerialConnectedToRemoteDebugger
extern

Shows if the debugger was connected to remote debugger (A remote host).

◆ g_LogOpened

BOOLEAN g_LogOpened
extern

Shows whether the '.logopen' command is executed and the log file is open or not.

◆ g_MessageHandler

PVOID g_MessageHandler
extern

The handler for ShowMessages function this is because the user might choose not to use printf and instead use his/her handler for showing messages.

◆ g_MessageHandlerSharedBuffer

PVOID g_MessageHandlerSharedBuffer
extern

The shared buffer for the handler of ShowMessages function.