private string BuildMessage() { StringBuilder sb = new StringBuilder(); // Print the IPC command details (service name, command ID, and handler) (Type callingType, MethodBase callingMethod) = WalkStackTrace(new StackTrace(this)); if (callingType != null && callingMethod != null) { var ipcService = Context.Session.Service; var ipcCommands = ipcService.Commands; // Find the handler for the method called var ipcHandler = ipcCommands.FirstOrDefault(x => x.Value.Method == callingMethod); var ipcCommandId = ipcHandler.Key; var ipcMethod = ipcHandler.Value; if (ipcMethod != null) { sb.AppendLine($"Service Command: {ipcService.GetType().FullName}: {ipcCommandId} ({ipcMethod.Method.Name})"); sb.AppendLine(); } } sb.AppendLine("Guest Stack Trace:"); sb.AppendLine(Context.Thread.GetGuestStackTrace()); // Print buffer information if (Request.PtrBuff.Count > 0 || Request.SendBuff.Count > 0 || Request.ReceiveBuff.Count > 0 || Request.ExchangeBuff.Count > 0 || Request.RecvListBuff.Count > 0) { sb.AppendLine("Buffer Information:"); if (Request.PtrBuff.Count > 0) { sb.AppendLine("\tPtrBuff:"); foreach (var buff in Request.PtrBuff) { sb.AppendLine($"\t[{buff.Index}] Position: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}"); } } if (Request.SendBuff.Count > 0) { sb.AppendLine("\tSendBuff:"); foreach (var buff in Request.SendBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}"); } } if (Request.ReceiveBuff.Count > 0) { sb.AppendLine("\tReceiveBuff:"); foreach (var buff in Request.ReceiveBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}"); } } if (Request.ExchangeBuff.Count > 0) { sb.AppendLine("\tExchangeBuff:"); foreach (var buff in Request.ExchangeBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}"); } } if (Request.RecvListBuff.Count > 0) { sb.AppendLine("\tRecvListBuff:"); foreach (var buff in Request.RecvListBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}"); } } sb.AppendLine(); } sb.AppendLine("Raw Request Data:"); sb.Append(HexUtils.HexTable(Request.RawData)); return(sb.ToString()); }