Prepare a printf-style message mapping and send string messages and tracing for logging and monitoring.
982{
983 int SprintfResult;
984 size_t WrittenSize;
987 char * LogMessage =
NULL;
988 char * TempMessage =
NULL;
989 char TimeBuffer[20] = {0};
990 ULONG CurrentCore = KeGetCurrentProcessorNumberEx(NULL);
991
992
993
994
996
997
998
999
1000
1001 if (IsVmxRootMode)
1002 {
1005 }
1006 else
1007 {
1008
1009
1010
1012
1013 if (LogMessage == NULL)
1014 {
1015
1016
1017
1019 }
1021
1022 if (TempMessage == NULL)
1023 {
1024
1025
1026
1029 }
1030 }
1031
1032 if (ShowCurrentSystemTime)
1033 {
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043 SprintfResult = vsprintf_s(TempMessage,
PacketChunkSize - 1, Fmt, ArgList);
1044
1045
1046
1047
1048 if (SprintfResult == -1)
1049 {
1050
1051
1052
1053 goto FreeBufferAndReturn;
1054 }
1055
1056
1057
1058
1059 TIME_FIELDS TimeFields;
1060 LARGE_INTEGER SystemTime, LocalTime;
1061 KeQuerySystemTime(&SystemTime);
1062 ExSystemTimeToLocalTime(&SystemTime, &LocalTime);
1063 RtlTimeToTimeFields(&LocalTime, &TimeFields);
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081 sprintf_s(TimeBuffer, RTL_NUMBER_OF(TimeBuffer), "%02hd:%02hd:%02hd.%03hd", TimeFields.Hour, TimeFields.Minute, TimeFields.Second, TimeFields.Milliseconds);
1082
1083
1084
1085
1086 SprintfResult = sprintf_s(LogMessage,
PacketChunkSize - 1,
"(%s - core : %d - vmx-root? %s)\t %s", TimeBuffer, CurrentCore, IsVmxRootMode ?
"yes" :
"no", TempMessage);
1087
1088
1089
1090
1091 if (SprintfResult == -1)
1092 {
1093
1094
1095
1096 goto FreeBufferAndReturn;
1097 }
1098 }
1099 else
1100 {
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110 SprintfResult = vsprintf_s(LogMessage,
PacketChunkSize - 1, Fmt, ArgList);
1111
1112
1113
1114
1115 if (SprintfResult == -1)
1116 {
1117
1118
1119
1120 goto FreeBufferAndReturn;
1121 }
1122 }
1123
1124
1125
1126
1127
1129
1130 if (LogMessage[0] == '\0')
1131 {
1132
1133
1134
1135 goto FreeBufferAndReturn;
1136 }
1137
1138
1139
1140
1142
1143FreeBufferAndReturn:
1144
1145 if (!IsVmxRootMode)
1146 {
1149 }
1150
1151 return Result;
1152}
unsigned int UINT32
Definition BasicTypes.h:48
unsigned long ULONG
Definition BasicTypes.h:37
#define PacketChunkSize
Size of each packet.
Definition Constants.h:179
BOOLEAN LogCallbackSendMessageToQueue(UINT32 OperationCode, BOOLEAN IsImmediateMessage, CHAR *LogMessage, UINT32 BufferLen, BOOLEAN Priority)
Send string messages and tracing for logging and monitoring.
Definition Logging.c:1203
BOOLEAN LogCheckVmxOperation()
Checks whether the message tracing operates on vmx-root mode or not.
Definition Logging.c:19
char * VmxTempMessage
VMX temporary buffer for logging messages.
Definition Logging.h:29
char * VmxLogMessage
VMX buffer for logging messages.
Definition Logging.h:23
PVOID PlatformMemAllocateNonPagedPool(SIZE_T NumberOfBytes)
Allocate a non-paged buffer.
Definition Mem.c:41
VOID PlatformMemFreePool(PVOID BufferAddress)
Free (dellocate) a non-paged buffer.
Definition Mem.c:86
NULL()
Definition test-case-generator.py:530