mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Add buf_to_hexstring
This commit is contained in:
parent
02a53c582c
commit
c98158b460
@ -214,6 +214,26 @@ void fmt_class_string<std::vector<char8_t>>::format(std::string& out, u64 arg)
|
||||
out.append(obj.cbegin(), obj.cend());
|
||||
}
|
||||
|
||||
template <>
|
||||
void fmt_class_string<fmt::buf_to_hexstring>::format(std::string& out, u64 arg)
|
||||
{
|
||||
const auto& _arg = get_object(arg);
|
||||
const std::vector<u8> buf(_arg.buf, _arg.buf + _arg.len);
|
||||
out.reserve(out.size() + (buf.size() * 3));
|
||||
static constexpr char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
for (usz index = 0; index < buf.size(); index++)
|
||||
{
|
||||
out += hex[buf[index] >> 4];
|
||||
out += hex[buf[index] & 15];
|
||||
|
||||
if (((index + 1) % 16) == 0)
|
||||
out += '\n';
|
||||
else
|
||||
out += ' ';
|
||||
}
|
||||
}
|
||||
|
||||
void format_byte_array(std::string& out, const uchar* data, usz size)
|
||||
{
|
||||
if (!size)
|
||||
|
@ -177,4 +177,13 @@ namespace fmt
|
||||
std::string to_lower(const std::string& string);
|
||||
|
||||
bool match(const std::string& source, const std::string& mask);
|
||||
|
||||
struct buf_to_hexstring
|
||||
{
|
||||
buf_to_hexstring(const u8* buf, usz len)
|
||||
: buf(buf), len(len) {}
|
||||
|
||||
const u8* buf;
|
||||
usz len;
|
||||
};
|
||||
}
|
||||
|
@ -986,25 +986,7 @@ error_code sceNpBasicSendMessageGui(vm::cptr<SceNpBasicMessageDetails> msg, sys_
|
||||
msg_data.data.assign(msg->data.get_ptr(), msg->data.get_ptr() + msg->size);
|
||||
}
|
||||
|
||||
if (sceNp.trace)
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
const u8* buf = msg->data.get_ptr();
|
||||
|
||||
for (u32 index = 0; index < msg->size; index++)
|
||||
{
|
||||
if ((index % 16) == 0)
|
||||
datrace += '\n';
|
||||
|
||||
datrace += hex[(buf[index] >> 4) & 15];
|
||||
datrace += hex[(buf[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
sceNp.trace("Message Data: %s", datrace);
|
||||
}
|
||||
sceNp.trace("Message Data:\n%s", fmt::buf_to_hexstring(msg->data.get_ptr(), msg->size));
|
||||
|
||||
bool result = false;
|
||||
|
||||
@ -1103,7 +1085,7 @@ error_code sceNpBasicRecvMessageAttachment(sys_memory_container_t containerId)
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sceNpBasicRecvMessageAttachmentLoad(ppu_thread& ppu, SceNpBasicAttachmentDataId id, vm::ptr<void> buffer, vm::ptr<u32> size)
|
||||
error_code sceNpBasicRecvMessageAttachmentLoad(SceNpBasicAttachmentDataId id, vm::ptr<void> buffer, vm::ptr<u32> size)
|
||||
{
|
||||
sceNp.warning("sceNpBasicRecvMessageAttachmentLoad(id=%d, buffer=*0x%x, size=*0x%x)", id, buffer, size);
|
||||
|
||||
@ -1135,6 +1117,7 @@ error_code sceNpBasicRecvMessageAttachmentLoad(ppu_thread& ppu, SceNpBasicAttach
|
||||
return SCE_NP_BASIC_ERROR_INVALID_DATA_ID;
|
||||
}
|
||||
|
||||
// Not sure about this
|
||||
// nph.clear_message_selected(id);
|
||||
|
||||
const auto msg_pair = opt_msg.value();
|
||||
@ -1144,24 +1127,7 @@ error_code sceNpBasicRecvMessageAttachmentLoad(ppu_thread& ppu, SceNpBasicAttach
|
||||
const u32 size_to_copy = std::min(static_cast<u32>(msg.data.size()), orig_size);
|
||||
memcpy(buffer.get_ptr(), msg.data.data(), size_to_copy);
|
||||
|
||||
if (sceNp.trace)
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
const u8* buf = static_cast<u8*>(buffer.get_ptr());
|
||||
for (u32 index = 0; index < size_to_copy; index++)
|
||||
{
|
||||
if ((index % 16) == 0)
|
||||
datrace += '\n';
|
||||
|
||||
datrace += hex[(buf[index] >> 4) & 15];
|
||||
datrace += hex[(buf[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
sceNp.trace("Message Data received: %s", datrace);
|
||||
}
|
||||
sceNp.trace("Message Data received:\n%s", fmt::buf_to_hexstring(static_cast<u8*>(buffer.get_ptr()), size_to_copy));
|
||||
|
||||
*size = size_to_copy;
|
||||
if (size_to_copy < msg.data.size())
|
||||
@ -1236,6 +1202,7 @@ error_code sceNpBasicRecvMessageCustom(u16 mainType, u32 recvOptions, sys_memory
|
||||
|
||||
nph.set_message_selected(att_data->data.id, chosen_msg_id);
|
||||
|
||||
// Is this sent if used from home menu but not from sceNpBasicRecvMessageCustom, not sure
|
||||
// sysutil_send_system_cmd(CELL_SYSUTIL_NP_INVITATION_SELECTED, 0);
|
||||
|
||||
nph.queue_basic_event(to_add);
|
||||
|
@ -334,22 +334,7 @@ void lv2_socket::save(utils::serial& ar, bool save_only_this_class)
|
||||
|
||||
void sys_net_dump_data(std::string_view desc, const u8* data, s32 len)
|
||||
{
|
||||
if (sys_net_dump.trace)
|
||||
{
|
||||
auto data_dump = fmt::format("%s:\n", desc);
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
for (s32 index = 0; index < len; index++)
|
||||
{
|
||||
if ((index % 16) == 0)
|
||||
data_dump += '\n';
|
||||
|
||||
data_dump += hex[(data[index] >> 4) & 15];
|
||||
data_dump += hex[(data[index]) & 15];
|
||||
data_dump += ' ';
|
||||
}
|
||||
sys_net.trace("%s", data_dump);
|
||||
}
|
||||
sys_net_dump.trace("%s:%s", desc, fmt::buf_to_hexstring(data, len));
|
||||
}
|
||||
|
||||
error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<u32> paddrlen)
|
||||
|
@ -28,20 +28,8 @@ template <>
|
||||
void fmt_class_string<libusb_transfer>::format(std::string& out, u64 arg)
|
||||
{
|
||||
const auto& transfer = get_object(arg);
|
||||
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
const int data_start = transfer.type == LIBUSB_TRANSFER_TYPE_CONTROL ? LIBUSB_CONTROL_SETUP_SIZE : 0;
|
||||
|
||||
for (int index = data_start; index < data_start + transfer.actual_length; index++)
|
||||
{
|
||||
datrace += hex[transfer.buffer[index] >> 4];
|
||||
datrace += hex[(transfer.buffer[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
fmt::append(out, "TR[r:%d][sz:%d] => %s", +transfer.status, transfer.actual_length, datrace);
|
||||
fmt::append(out, "TR[r:%d][sz:%d] => %s", +transfer.status, transfer.actual_length, fmt::buf_to_hexstring(&transfer.buffer[data_start], transfer.actual_length));
|
||||
}
|
||||
|
||||
struct UsbLdd
|
||||
@ -951,20 +939,9 @@ error_code sys_usbd_transfer_data(ppu_thread& ppu, u32 handle, u32 id_pipe, vm::
|
||||
if (sys_usbd.trace && request)
|
||||
{
|
||||
sys_usbd.trace("RequestType:0x%x, Request:0x%x, wValue:0x%x, wIndex:0x%x, wLength:0x%x", request->bmRequestType, request->bRequest, request->wValue, request->wIndex, request->wLength);
|
||||
|
||||
if ((request->bmRequestType & 0x80) == 0 && buf && buf_size != 0)
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
for (u32 index = 0; index < buf_size; index++)
|
||||
{
|
||||
datrace += hex[(buf[index] >> 4) & 15];
|
||||
datrace += hex[(buf[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
sys_usbd.trace("Control sent: %s", datrace);
|
||||
}
|
||||
sys_usbd.trace("Control sent:\n%s", fmt::buf_to_hexstring(buf.get_ptr(), buf_size));
|
||||
}
|
||||
|
||||
auto& usbh = g_fxo->get<named_thread<usb_handler_thread>>();
|
||||
@ -1023,19 +1000,8 @@ error_code sys_usbd_transfer_data(ppu_thread& ppu, u32 handle, u32 id_pipe, vm::
|
||||
{
|
||||
// If output endpoint
|
||||
if (!(pipe.endpoint & 0x80))
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
sys_usbd.trace("Write Int(s: %d):\n%s", buf_size, fmt::buf_to_hexstring(buf.get_ptr(), buf_size));
|
||||
|
||||
for (u32 index = 0; index < buf_size; index++)
|
||||
{
|
||||
datrace += hex[buf[index] >> 4];
|
||||
datrace += hex[buf[index] & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
sys_usbd.trace("Write Int(s: %d) :%s", buf_size, datrace);
|
||||
}
|
||||
pipe.device->interrupt_transfer(buf_size, buf.get_ptr(), pipe.endpoint, &transfer);
|
||||
}
|
||||
|
||||
|
@ -102,22 +102,8 @@ namespace np
|
||||
s32 dnshook::analyze_dns_packet(s32 s, const u8* buf, u32 len)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
if (dnshook_log.trace)
|
||||
{
|
||||
std::string datrace;
|
||||
const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
for (u32 index = 0; index < len; index++)
|
||||
{
|
||||
if ((index % 16) == 0)
|
||||
datrace += '\n';
|
||||
|
||||
datrace += hex[(buf[index] >> 4) & 15];
|
||||
datrace += hex[(buf[index]) & 15];
|
||||
datrace += ' ';
|
||||
}
|
||||
dnshook_log.trace("DNS REQUEST: %s", datrace);
|
||||
}
|
||||
dnshook_log.trace("DNS REQUEST:\n%s", fmt::buf_to_hexstring(buf, len));
|
||||
|
||||
struct dns_header
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ bool recvmessage_dialog_frame::Exec(SceNpBasicMessageMainType type, SceNpBasicMe
|
||||
{ accept_or_deny(SCE_NP_BASIC_MESSAGE_ACTION_ACCEPT); });
|
||||
connect(btn_deny, &QAbstractButton::clicked, this, [&accept_or_deny]()
|
||||
{ accept_or_deny(SCE_NP_BASIC_MESSAGE_ACTION_DENY); });
|
||||
connect(btn_cancel, &QAbstractButton::clicked, this, [m_dialog=this->m_dialog]()
|
||||
connect(btn_cancel, &QAbstractButton::clicked, this, [this]()
|
||||
{ m_dialog->close(); });
|
||||
connect(this, &recvmessage_dialog_frame::signal_new_message, this, &recvmessage_dialog_frame::slot_new_message);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user